-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathassignment_11_1_2022.py
55 lines (37 loc) · 1.05 KB
/
assignment_11_1_2022.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
# 1. create a for loop that prints 8 rows of stars spaced going right
def star_rows():
for i in range(1, 9):
print('*' * i)
star_rows()
# create a for loop that prints 8 rows of stars spaced going left to right
def star_rows_left():
for i in range(1, 9):
print(' ' * (8 - i), '*' * i)
star_rows_left()
# 2. create a for loop that prints up to 20 but skips 15
def skip_15():
for i in range(1, 21):
if i == 15:
continue
print(i)
# skip_15()
def print_pyramid():
for i in range(1, 6):
print(' ' * (5 - i), '*' * (2 * i - 1))
def pyramid_inverse():
for i in range(1, 6):
print(' ' * i, '*' * (2 * (5 - i) - 1))
pyramid_inverse()
print_pyramid()
# 3. create a dictionary and using a for loop print only values
def create_dict():
fav_cars = {
'ford': 'mustang',
'chevy': 'camaro',
'dodge': 'challenger',
'jeep': 'wrangler'
}
# using a for loop print only values
for value in fav_cars.values():
print(value)
create_dict()