-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditionals.py
More file actions
72 lines (60 loc) · 1.24 KB
/
conditionals.py
File metadata and controls
72 lines (60 loc) · 1.24 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
""""
This module practice working with conditionals.
if, elif, else
"""
# Comparisons:
# Equal: 3 == 2
# Not Equal: 3 != 2
# Greater Than 3 > 2
# Less Than 3 < 2
# Greater or Equal: 3 >= 2
# Less or Equal: 3 <= 2
# is: Object Identity
# Logical Operators:
# and
# or
# not
language = "JavaScript"
if language == "Python":
print("This is Python Language.")
elif language == "Java":
print("This is Java Language.")
elif language == "JavaScript":
print("This is JavaScript Language.")
else:
print("No Match.")
user = "Admin"
logged_in = True
if user == "Admin" and logged_in:
print("Admin page")
elif user == "User" and logged_in:
print("User Dashboard")
elif not logged_in:
print("Please login")
else:
print("Welcome")
a = [1, 2, 3]
b = [1, 2, 3]
print(a == b)
print(a is b)
print(id(a))
print(id(b))
c = [1, 2, 3]
d = c
print(c == d)
print(c is d)
print(id(c))
print(id(d))
# False Values:
# False
# None
# Zero of any numeric type
# Any empty sequence. For example, '', (), []
# Any empty mapping. For example, {}
print(False == True)
print(None == True)
print(0 == True)
print('' == True)
print(() == True)
print([] == True)
print({} == True)