-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor-loop.py
More file actions
33 lines (30 loc) · 786 Bytes
/
for-loop.py
File metadata and controls
33 lines (30 loc) · 786 Bytes
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
# use this for loop to execute the result in the following manner
# 011222
for i in range(0,3):
for j in range(0,3):
print(i)
# use this for loop to execute the result in the following manner
# 000111222
for i in range(0,3):
for j in range(0,3):
print(i, end='')
# use this for loop to execute the result in the following manner
# *
# * *
# * * *
for i in range(0,3):
for j in range(0,i+1):
print('*', end=' ')
print('\n')
# use this for loop to execute the result in the following manner
# *
# ***
# *****
for i in range(1, 4):
for j in range(i, 4):
print(" ", end='')
for k in range(0, i):
print('*', end='')
for m in range(1, i):
print('*', end='')
print('\n')