You are on page 1of 6

2/22/22, 8:15 PM 1.2.1.

Variables (1) - Jupyter Notebook

Features of Python
In [ ]:

designed by: Guido Van Rossum in 20 Feb 1991


and the first offficial version of python was 0.9.0
currently 3.11.0 version thats in release & 3.9.1 version used in Anaconda

In [ ]:

Why Python?

1. Simplest language amongst all.


2. Simple to learn, simple to debug.
3. Free & open source.
4. Globally available.
5. It also has a vast library support.
6. almost 70-75% of data scientist use Python as their primary language for programming.
7. Programming friendly language (easy to write codes, read & script)
8. It supports both Procedural programming & object oriented programming (Functions & class
9. Python is also interprited language.
10. Most widly used language.
11. Dynamically Types language. (we need not mention the data type of the variable). No nee
12. Most simplest languages. Almost Feels like we are reading english.

In [7]:

1651321 + 16543213

Out[7]:

18194534

Variables
Defination - Variables are containers or entities that stores data or information.

In [ ]:

Rules to define variables:


1. Letters (a-z, A-Z, 0-9)
2. It can also contain (_)
3. Only special character allowed is (_)
4. Case Sensitive
5. Variables should not start with numbers(0-9).
*Note: No number, function name or class name or variable should start with 0.
6. It should not contain special characters (!@#$%^&*+?><,.) and reserved keywords (and
7. we can use multiple variables in single line using , or ;

In [10]:

my_variable = 1651321 + 16543213

localhost:8888/notebooks/1.2.1. Variables (1).ipynb 1/6


2/22/22, 8:15 PM 1.2.1. Variables (1) - Jupyter Notebook

In [11]:

my_variable

Out[11]:

18194534

In [12]:

my_variable-1000

Out[12]:

18193534

In [13]:

a = 5
a

Out[13]:

In [14]:

id(a)

Out[14]:

140711707617200

In [17]:

B = 10
id(B)

Out[17]:

140711707617360

In [16]:

c = 5
id(c)

Out[16]:

140711707617200

In [19]:

A1 = 111
A1

Out[19]:

111

localhost:8888/notebooks/1.2.1. Variables (1).ipynb 2/6


2/22/22, 8:15 PM 1.2.1. Variables (1) - Jupyter Notebook

In [20]:

1A = 112
1A

File "<ipython-input-20-0ed1001e44dd>", line 1

1A= 112

SyntaxError: invalid syntax

In [21]:

A1b = 555
A1b

Out[21]:

555

In [22]:

@a = 9
@a

File "<ipython-input-22-3e0172a15e09>", line 1

@a = 9

SyntaxError: invalid syntax

In [23]:

a b = 2020
a b

File "<ipython-input-23-9415a376b234>", line 1

a b = 2020

SyntaxError: invalid syntax

In [24]:

a%b=1010
a%b

File "<ipython-input-24-8cfcfdf21b13>", line 1

a%b=1010

SyntaxError: cannot assign to operator

localhost:8888/notebooks/1.2.1. Variables (1).ipynb 3/6


2/22/22, 8:15 PM 1.2.1. Variables (1) - Jupyter Notebook

In [25]:

a_b=3030
a_b

Out[25]:

3030

In [28]:

A_b

---------------------------------------------------------------------------

NameError Traceback (most recent call last)

<ipython-input-28-4b3c8f3eba3a> in <module>

----> 1 A_b

NameError: name 'A_b' is not defined

In [26]:

class = 6
class

File "<ipython-input-26-e244eb9daba3>", line 1

class = 6

SyntaxError: invalid syntax

In [27]:

any = 20
any

Out[27]:

20

In [29]:

x=15
x=25
x

Out[29]:

25

In [30]:

_home= 'camp area, Pune'


_home

Out[30]:

'camp area, Pune'

localhost:8888/notebooks/1.2.1. Variables (1).ipynb 4/6


2/22/22, 8:15 PM 1.2.1. Variables (1) - Jupyter Notebook

In [31]:

Ram_Mote = 98
Ram_Mote

Out[31]:

98

In [32]:

Ram, Mote = 95, 98

Ram

Out[32]:

95

In [33]:

Mote

Out[33]:

98

In [34]:

Ram = 95; Mote= 98

Ram, Mote

Out[34]:

(95, 98)

In [35]:

Ram_Mote

Out[35]:

98

In [36]:

ram_mote

---------------------------------------------------------------------------

NameError Traceback (most recent call last)

<ipython-input-36-8a3733a37bb8> in <module>

----> 1 ram_mote

NameError: name 'ram_mote' is not defined

localhost:8888/notebooks/1.2.1. Variables (1).ipynb 5/6


2/22/22, 8:15 PM 1.2.1. Variables (1) - Jupyter Notebook

In [ ]:

MYVAR >> valid


mYVar5 >> Valid
007james_bond >> Invalid
7james_bond >> Invalid
My^var >> Invalid
_abc >> Valid
import >>invalid
elif >> invalid
Elif >> valid

localhost:8888/notebooks/1.2.1. Variables (1).ipynb 6/6

You might also like