-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogramarcadegames_lab_6.3_with_formatting.py
56 lines (48 loc) · 1.31 KB
/
programarcadegames_lab_6.3_with_formatting.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
'''
I actually made it work with double digit numbers as well :)
Assignment:
Print the following for any positive integer n. Use an input statement to allow the user to enter
the value for n and then print the properly sized box.
E.g. n = 3
1 3 5 5 3 1
3 5 5 3
5 5
5 5
3 5 5 3
1 3 5 5 3 1
E.g. n = 5
1 3 5 7 9 9 7 5 3 1
3 5 7 9 9 7 5 3
5 7 9 9 7 5
7 9 9 7
9 9
9 9
7 9 9 7
5 7 9 9 7 5
3 5 7 9 9 7 5 3
1 3 5 7 9 9 7 5 3 1
'''
user_choice = int(input("Please enter a number: "))
m = 2*user_choice
#triangle 1
for i in range (0, user_choice):
for j in range ((i*2)+1, m, 2):
print ("{:2}".format(j), end=" ")
for j in range (i):
print ("{:2}".format(" "), end=" ")
for j in range (i):
print ("{:2}".format(" "), end= " ")
for j in range (m-1, i*2, -2):
print ("{:2}".format(j), end=" ")
print()
#triangle 2
for i in range (0, user_choice):
for j in range ((m-1)-i*2, m, 2):
print ("{:2}".format(j), end=" ")
for j in range (1, user_choice-i):
print ("{:2}".format(" "), end=" ")
for j in range (1, user_choice-i):
print ("{:2}".format(" "), end=" ")
for j in range (m-1, (m-2)-i*2, -2):
print ("{:2}".format(j), end=" ")
print()