You are on page 1of 4

Identifiers : A name in python program is called identifiers.

It can be
class name or function name or module name or variable name.

Rules:

1) only alphabet symbol allowed (a-z , A-Z, 0-9, '_')

By mistake if we are using any other symbol like $ thenwe will get
syntax error:

cash = 10 => correct

ca$h = 10 => incorrect

2) 123total => incorrect

total123 => correct

3) Identifiers are case sensitive :

total = 10

TOTAL = 999;

both are the different variable.

4) def = 10 => wrong

bcz def is keyword which is used to construct the function

5) There is no length limit for Identifiers . But not recommended to use


too lengthy identifiers.

Note :

1) if identifiers start with '_' symbol then it indicates that it is private.

2) If identifiers starts with '_ _'(two underscore) indicating that strongly


private identifiers.

3) If the identifiers starts and end with two underscore symbol then the
identifiers is language defined special name, which is also known as
magic method.

e.g. _ _ add _ _

Reserved Words

In python some words are reserved to represent some meaning or


functioning.

There are 33 reserved words avaliable:

--> True,False,None

---> and,or, not, is

---> if,elif,else

---> while,for,break,continue,return,yield,in

----> try,except,finally, raise, assert

----> import ,from, as, class, def, pass, global, nonlocal, lambda,
del,with.

e.g . a = true => incorrect

a = True => correct

Data types

Python contains the following inbuilt data type :

int, float, complex, bool, str, bytes, bytearray, range, list, tuple,
set,frozenset, dict, None

inbuilt function:

1.type() : to check the type of variable

2. id() : to get address of

3. print(): to print the value

Note : we can represent int value in decimal ,binary, octal,


hexadecimal, But we can represent float value only by using decimal
form.

complex data type :

complex number is in the form of

a + bj

a = real part

bj = imaginary part

/4 = 2 / 41 =

str data type :

s1 = "amol"

s2 = 'amol'

e.g . s1 = 'amol'

s[0] = a = s[-4]

s[1] = m = s[-3]
s[2] = o = s[-2]

s[3] = l = s[-1]

You might also like