Multiplication tables: Difference between revisions

→‎{{header|Python}}: better looking output.
m (→‎{{header|C++}}: geshi likes cpp, I suppose.)
(→‎{{header|Python}}: better looking output.)
Line 180:
 
=={{header|Python}}==
<lang python>>>> forsize row= in range(13):12
>>> for row in range(-1,size+1):
print(" ".join("%3s" % ("x" if row==col==0
else row if row and col==0:
print("─"*3 + "┼"+"─"*(4*size-1))
else col if row==0
else:
else "" if row>col
print(" ".join("%3s%1s" % (("x","│") if row==-1 and col==0
else row*col)
else (row,"│") if row>0 for and col in range(13)))==0
else (col,"") if row==0-1
else ("","") if row>col
else (row*col,""))
for col in range(size+1)))
 
x 1 2 3 4 5 6 7 8 9 10 11 12
1 x│ 1 2 3 4 5 6 7 8 9 10 11 12
───┼───────────────────────────────────────────────
2 4 6 8 10 12 14 16 18 20 22 24
31│ 1 2 3 94 12 5 15 186 21 7 24 278 30 9 33 10 11 12 36
42│ 4 6 8 1610 2012 2414 2816 3218 3620 4022 44 24 48
53│ 9 12 15 18 2521 3024 3527 40 45 30 50 33 55 36 60
64│ 16 20 24 28 32 36 4240 4844 54 60 66 48 72
75│ 25 30 35 40 45 49 50 56 55 63 60 70 77 84
86│ 36 42 48 54 60 64 66 72 80 88 96
97│ 49 56 63 70 77 81 84 90 99 108
10 8│ 64 72 80 10088 110 12096
11 9│ 81 90 99 108 121 132
1210│ 100 110 120 144
11│ x 1 2 3 4 5 6 7 8 9 10 11 12 121 132
12│ 2 4 6 8 10 12 14 16 18 20 22 24 144
>>> </lang>
 
Anonymous user