Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Homework exercise
# python 3.5.2 # https://1drv.ms/f/s!ArsHV2FdZgQ1iQOclKKq2kqbxLdg # Homework exercise - Use for/while loops for completing the following design # * 3 blanks, 1 star # *** 2 blanks, 3 star # ***** 1 blanks, 5 star # ******* 0 blanks, 7 star # *** 2 blanks, 3 star # ***** 1 blanks, 5 star # ******* 0 blanks, 7 star # ||| 3 blanks, 3 line # ||| 3 blanks, 3 line i=0 for i in range(9): if i<=4: print(i, ' '*(4-i) + '*'*(i*2-1)) if 5<=i<=7: print(i, ' '*(7-i) + '*'*((i-5)*2+3)) if i>=8: print(i, ' '*2 + '|'*3) #........................................... i=0 while i<9: i=i+1 if i<=4: print(i, ' '*(4-i) + '*'*(i*2-1)) if 5<=i<=7: print(i, ' '*(7-i) + '*'*((i-5)*2+3)) if i>=8: print(i, ' '*2 + '|'*3)
run
|
edit
|
history
|
help
0
lhp-1
pythonic way (V2)
List problem - add items
just Comment
StringManipulation
test
Bubble sort
binary_search
0-1 Knapsack
json array object loop