Identifiers and Operators in python

Identifiers

Ex:
a=10
b=’xyz’

Here a And b are identifiers.

Identifiers can start with _ or a-z or A-Z  & alphabet followed by number (0-9)  but not with 0-9

# Starting of python programing
'''
Multy line comment
bla bla bla
and that it
'''

print("This is very begging")

a=10
b='xyz'
print(a,b)

_a = 50
print(_a)

_2 = 'xyz'
print(2)

_A = 1000
print(_A)

__x__ = 20
print(__x__)

_a0 = 'multy combination'
print (_a0)

o/p

This is very begging
(10, ‘xyz’)
50
2
1000
20
multy combination

Operators

Operator can be Arithmetic, logical, comparison, bitwise, membership, Assignment, Identity .

Arithmetic 
+ (Addition)
– (Subtraction)
* (Multiplication)
/ (Division)
% (Modulus)
** (exponent)
//(floor division)

Assignment 
Assign value from right to left a =b
a = a+b ==> a += b
a = a-b ==> a -= b
a = a*b ==> a *= b
a = a/b ==> a /= b
a = a**b ==> a **= b
a = a//b ==> a //= b

Comparison
==, != , >, <, >=, <=

Logical
And, or, Not

Bitwise
a&b and
a|b or
a^b xor
a~b binary not
a<< left shift a>> right shift

Identity
is
is not

Membership
in
not in

 

 

 

 

Leave a comment