-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathifelsefunc.py
executable file
·37 lines (28 loc) · 1011 Bytes
/
ifelsefunc.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
year = 2012
realYear = 2017
if year == realYear:
print("Yup, this is the year!")
else:
print("Nope, that's not it")
# if year and realYear are equivalent, it'll print the first one. if not, it'll
# print the second one. the first print statement is dependent on the if
# statement, same goes with the second print statement.
# print is a built in function
fruit1 = "mango"
fruit2 = "kiwi"
if fruit1 == fruit2:
print("They're the same fruit!")
print("I love fruit!")
else:
print("They're not the same fruit at all")
print("But they taste really good together")
# they're not equal, so the else statement prints out
# in the if/else statement function, it MUST be indented
if fruit1 == fruit2:
print("They're the same fruit!")
print("I love fruit!")
else:
print("They're not the same fruit at all")
print("But they taste really good together")
print("I don't like fruit")
# the last print statement isn't dependent of the if or else block. so, it will always execute when the code block is run