-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbool.py
More file actions
44 lines (38 loc) · 760 Bytes
/
Copy pathbool.py
File metadata and controls
44 lines (38 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Bool (True or False)
a=int(input('enter any number'))
b=int(input('enter second number'))
print(a==b)
print(b>a)
print(a>b)
# with if else
if a>b:
c="{0} is greater then {1}"
print(c.format(a,b))
else:
c="{1} is greater then {0}"
print(c.format(a,b))
# only empty string and 0 are shown as False all other are true
print(bool("VIKRANT"))
print(bool(5e6))
print(bool(0))
print(bool())
# other Fasle values are
"""
bool(False)
bool(None)
bool(0)
bool("")
bool(())
bool([])
bool({})
"""
# function that bool is Fasle
class myclass():
def __len__(self):
return 0
myobj = myclass()
print(bool(myobj))
# (isinstance(variable, condition to be true)) aslo use to find a variable is data type
x=24
print(isinstance(x,int))
print(isinstance(x,float))