-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliens.py
37 lines (30 loc) · 1.04 KB
/
aliens.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
# alien_0_info = {'color': 'green', 'points': 5}
# alien_1_info = {'color': 'yellow', 'points': 10}
# alien_2_info = {'color': 'red', 'points': 15}
# aliens_info = [alien_0_info,
# alien_1_info,
# alien_2_info,
# ]
# for alien_info in aliens_info:
# print(alien_info)
import random
aliens = []
for x in range (30):
alien_x_info = {
'color': random.choice(['green', 'red', 'yellow']),
'points': random.choice([5, 10, -7]),
'speed': random.choice(['slow', 'medium', 'fast']),
}
aliens.append(alien_x_info)
print(f"The initial state of aliens is:\t")
for alien in aliens[0:10]:
print(alien)
# print(f"\nA total of {len(aliens)} aliens are created.")
for alien in aliens[0:10]:
if (alien['color'] == 'green') and (alien['speed'] == 'fast'):
alien['color'] = 'yellow'
elif (alien['color'] == 'yellow') and (alien['speed'] == 'fast'):
alien['color'] = 'red'
print(f"\nThe modified state of aliens is:\t")
for alien in aliens[0:10]:
print(alien)