-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_exercise_page65.py
More file actions
73 lines (45 loc) · 1.47 KB
/
python_exercise_page65.py
File metadata and controls
73 lines (45 loc) · 1.47 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
72
73
# esercizio numero 4.10 pagina 65
favorite_food = ['pasta', 'pizza', 'lasagne', 'pizzocheri', 'gelato']
print(favorite_food)
print("The first three items in the list are:")
print(favorite_food[0:3])
print("Three items from the middle of the list are:")
print(favorite_food[1:4])
print("The last three items from the list are:")
print(favorite_food[-3:])
# esercizio numero 4.11
my_pizzas = ['margherita', 'prosciutto e funghi', 'diavola', 'porcini']
friend_pizzas = my_pizzas[:]
print("My favorite pizzas are:")
print(my_pizzas)
friend_pizzas.append('marinara')
print("\nMy favorite friend's pizzas are:")
print(friend_pizzas)
for pizza in my_pizzas[0:]:
print(pizza)
for pizza in friend_pizzas[0:]:
print(pizza)
# esercizio numero 4.12
my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]
print("My favorite foods are:")
print(my_foods)
print("\nMy friend's favorite foods are:")
print(friend_foods)
for food in my_foods[0:]:
print(food)
for foods in friend_foods[0:]:
print(foods)
# ulteriore variante dell' esercizio numero 4.12
my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]
my_foods.append('cannoli')
friend_foods.append('ice cream')
print("My favorite foods are:")
print(my_foods)
print("\nMy friend's favorite foods are:")
print(friend_foods)
for food in my_foods[0:]:
print(food)
for foods in friend_foods[0:]:
print(foods)