-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionals.py
42 lines (34 loc) · 859 Bytes
/
conditionals.py
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
#
# Example file for working with conditional statements
# LinkedIn Learning Python course by Joe Marini
#
def main():
x, y = 1000, 1000
lt = 'x is less than y'
eq = 'x is the same as y'
gt = 'x is greater than y'
# # conditional flow uses if, elif, else
# if x < y:
# result = lt
# elif x==y:
# result = eq
# else:
# result = gt
# print(result)
# # conditional statements let you use "a if C else b"
# result = lt if x < y else gt
# print(result)
# match-case makes it easy to compare multiple values
value = "one"
match value:
case "one":
result = 1
case 'two':
result = 2
case 'three'|'four':
result = (3,4)
case _:
result = -1
print(result)
if __name__ == "__main__":
main()