-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter_IV.py
62 lines (47 loc) · 1.37 KB
/
Chapter_IV.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
56
57
58
59
60
61
62
pioneers=['elon','altman','albus','cauchy']
for pioneer in pioneers:
print(pioneer)
for value in range(1,4):
print(value)
numbers=list(range(3,9,2))
print(numbers)
squares=[] #etablish a blank list
for value in range(3,13): #use "for" to circulate
square=value**2 #culculation
squares.append(square) #insert value at the END of the list
print(squares)
numbers=[1,2,3,4,5,6,7,8,8] #value in lists could be repeated
min(numbers)
max(numbers)
sum(numbers)
squares=[value**2 for value in range(2,5)]
print(squares)
for number in range(1,21):
print(number)
numbers=list(range(1,101))
print(numbers)
max(numbers)
min(numbers)
sum(numbers)
numbers=list(range(1,21,2))
for number in numbers:
print(number)
numbers=[value**3 for value in range(1,11)]
print(numbers)
players=["a",'b','c','d','e','f']
for player in players[:2]:
print(player.title())
print("The first three items in the list are:")
print(players[:3])
players.append("g")
print(players)
pizzas=['ab','cd','ef','gh']
friend_pizzas=pizzas[:]
pizzas.append("ij")
friend_pizzas.append("kl")
print("My favorite pizzas are:")
for pizza in pizzas:
print(pizza)
print("My friend's favorite pizzas are:")
for pizza in friend_pizzas:
print(pizza)