-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathifstatement2.py
55 lines (39 loc) · 1.06 KB
/
ifstatement2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
age = int(input("How old are you? "))
# using and operator
if (age >= 16) and (age <= 65):
print("Have a good day at work")
else:
print("Enjoy this free time")
# using or
if (age < 16) or (age > 65):
print("Enjoy your free time")
else:
print("Have a good day at work")
x = input("Please enter some text: ")
if x:
print("You entered '{}' ".format(x))
else:
print("You didn't enter anything, that sucks")
# using not
print(not False)
print(not True)
new_age = int(input("How old are you? "))
if not(new_age < 18):
print("You're old enough to vote")
print("Cast you ballot")
else:
print("You're only {0}, come back in {1} years".format(new_age, 18 - new_age))
# using in
parrot = "African Grey"
letter = input("Enter a character: ")
if letter in parrot:
print("That's what we're looking for {}, good job".format(letter))
else:
print("No, that's not it")
# using not & in
parrot = "African Grey"
letter = input("Enter a character: ")
if letter not in parrot:
print("No, that's not it")
else:
print("That's what we're looking for {}, good job".format(letter))