Python (ch2)
Python (ch2)
>>> 42 == 42
True
>>> 42 == 99
False
>>> 2 != 3
True
>>> 2 != 2
False
True
False
True
>>> 42 == ‘42’
False
True
a=(1,2,3)
if type(a) in (int,float,complex,bool):
print('single value')
else:
print('collection value')
o/p—
Collection value
while condition:
# body of while loop
Here,
1.The while loop evaluates the condition.
2.If the condition is true, body of while loop is executed.
The condition is evaluated again.
3.This process continues until the condition is False.
4.Once the condition evaluates to False, the loop terminates.
◦ o/p—
◦ S
◦ T
◦ R
◦ I
◦ N
◦ g
0
1
2
import sys
temp = 100
if temp == 100:
(python exit function sys.exit, is a built –in method used to terminate a python
Script)