-
Notifications
You must be signed in to change notification settings - Fork 0
/
chapter_6_Advanced_looping_Lab6.2.py
65 lines (60 loc) · 1.9 KB
/
chapter_6_Advanced_looping_Lab6.2.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
63
64
65
#I am not sure if this is the correct way to be done
#but apparently it is working for any inputed number
#provided it is an int. I'm not yet there to ask the
#user for only specific numbers. This will come.
#I based my program on the example given not in the
#assignment but in the building area.
'''
Create a big box out of n rows of little o's for any desired size 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
oooooo
o o
oooooo
E.g. n = 8
oooooooooooooooo
o o
o o
o o
o o
o o
o o
oooooooooooooooo
'''
#get input from user
user_input = int(input("Input a number: "))
#as seen from example the top and bottom are twice the input from user
top_and_bottom_range = 2*user_input
#placeholder for spaces to be used
space_var = " "
for i in range (0, top_and_bottom_range):
print ("o", end="")
print()
for i in range (0, user_input+1):
if user_input == 1:
print ("oo")
else:
print ("o", (top_and_bottom_range-4)*space_var, "o")
for i in range (0, top_and_bottom_range):
print ("o", end = "")
#####################################Second Possibility as shown in assignemnt example#############################
# E.g. n = 3
# oooooo
# o o
# oooooo
###################################################################################################################
#get input from user
user_input = int(input("Input a number: "))
#as seen from example the top and bottom are twice the input from user
top_and_bottom_range = 2*user_input
space_var = " "
for i in range (0, top_and_bottom_range):
print ("o", end="")
print()
for i in range (1, user_input-1):
if user_input == 1:
print ("oo")
else:
print ("o", (top_and_bottom_range-4)*space_var, "o")
for i in range (0, top_and_bottom_range):
print ("o", end = "")