-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagic_number.py
More file actions
62 lines (36 loc) · 1.02 KB
/
Copy pathmagic_number.py
File metadata and controls
62 lines (36 loc) · 1.02 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
answer = 17
if answer != 42:
print("That is not the correct answer. Please try again!")
answer = 24
if answer == 24:
print("That's the correct answer! You won!")
age = 19
print(age < 21 )
age <= 21
print(age < 21)
age < 21
print(age > 21)
age >= 21
print(age > 21)
# check if two people are both over 21
age_0 = 22
age_1 = 18
print(age_0 >= 21 and age_1 >= 21)
age_1 = 22
print(age_0 >= 21 and age_1 >= 21)
# di seguito lo stesso codice ma con le parentesi (facilmente leggibile)
age_0 = 22
age_1 = 18
print((age_0 >= 21) and (age_1 >= 21))
age_1 = 21
print((age_0 >= 21) and (age_1 >= 21))
#utilizzare or per verificare condizioni multiple
age_0 = 22
age_1 = 18
print(age_0 >= 21 or age_1 >= 21)
age_0 = 18
print(age_0 >= 21 or age_1 >= 21)
# utilizzare in per controllare se un valore è in una lista
requested_toppings = ['mushrooms', 'onions', 'pineapple']
print('mushrooms' in requested_toppings)
print('pepperoni' in requested_toppings)