-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable_99.py
More file actions
45 lines (34 loc) · 716 Bytes
/
table_99.py
File metadata and controls
45 lines (34 loc) · 716 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
34
35
36
37
38
39
40
41
42
43
44
# Multiplication table
# version 1
for i in range(1, 10):
for j in range(1, i+1):
print(str(j)+'*'+str(i)+'='+str(i*j),end=' ')
print()
print()
# version 2
for i in range(1, 10):
for j in range(1, i+1):
product = i*j
if j > 1 and product < 10:
product = str(product) + ' '
print(str(j)+'*'+str(i)+'='+str(product), end=' ' )
print()
print()
# version 3
for i in range(1, 10):
print(' '*7*(i-1), end='' )
for j in range(i, 10):
product = i*j
if product < 10:
end = ' '
else:
end = ' '
print(str(i)+'*'+str(j)+'='+str(i*j),end=end)
print()
print()
# version 4
for i in range(1,10):
line = ''
for j in range(1, i+1):
line += '{}*{}={:<3}'.format(j, i, i*j)
print(line)