-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path006_control_flow.py
More file actions
71 lines (50 loc) · 1.17 KB
/
006_control_flow.py
File metadata and controls
71 lines (50 loc) · 1.17 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
# Boolean in Python
# True or False
# Delhi is India Capital city -- This is boolean as it is True
# Relational Operators
# The two boolean operators we’ll cover first are:
# Equals: ==
# Not equals: !=
# Greater than: >
# Less than: <
# Greater than or equal to: >=
# Less than or equal to: <=
# if condition
# code
# Python function with if condition
def check_true(num1, num2):
if num1 > num2:
return True
if num1 < num2:
return False
print(check_true(10, 50))
# Boolean Operators
# and
# or
# not
# For and
# True True True
# True False False
# False True False
# False False False
# For or
# True True True
# True False True
# False True True
# False False False
def i_am_py_func_and_or(x, y):
if x == 10 and y == 10:
return True
if x == 10 or y < 10:
return False
print(i_am_py_func_and_or(10, 10))
print(i_am_py_func_and_or(10, 9))
# there is one more way to write the above function
# we can also use else statement with if
def i_am_py_func_with_else(x, y):
if x > y:
return x
else:
return y
print(i_am_py_func_with_else(10, 4))
print(i_am_py_func_with_else(30, 69))