Python Variable, Datatype, Operators

Python Basics

print('Python means Silan Software')
Output

Python means Silan Software


x=100
print(x)

Output

100


type(x)
Output

int


y=12.34
print(y)

Output

12.34


type(y)
Output

float


s='python programming'
print(s)
Output

python programming


type(s)
Output

str


z=True
print(z)
Output

True


type(z)
Output

bool


x+y
Output

112.34


#Python Arithmetic Opertaors(+ - * / // % **)
x=5
y=3
x+y
Output

8


x-y
Output

2


x*y
Output

15


x/y
Output

1.6666666666666667


x//y
Output

1


x%y
Output

2


x**y
Output

125


#Python Comparison Operators(< <= > >= == !=)
#In this context the output value must be a boolean value(True / False)
x<=y
Output

False


x>=y
Output

True


x==y
Output

False


x!=y
Output

True


#Python Logical Operators(and or not)
x+y>y and x!=y

Output

True


x+y<y or x==y

Output

False


x and y
Output

3


x or y
Output

5


not x+y<y
Output

True


#Python Assignment Operator(=)
x1=200
print(x1)
Output

200


x1+=50
print(x1)
Output

250


#Python Bitwise Operators
x & y
Output

1


x | y
Output

7


x ^ y
Output

6


~x
Output

-6


x<<3
Output

40


x>>2
Output

1


#Python Identity Operators(is is not)
x1=100
x2=100
y1=[10,20,30,40,50]
y2=[10,20,30,40,50]


x1 is x2
Output

True


y1 is y2
Output

False


y1 is not y2
Output

True


#Python Membership Operators(in not in)
s="Hello World!"

'h' in s
Output

False


'h' not in s
Output

True


'H' in s
Output

True


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 Previous