aboutsummaryrefslogtreecommitdiff
path: root/challenge-033/paulo-custodio/python/ch-2.py
diff options
context:
space:
mode:
authorConor Hoekstra <codereport@outlook.com>2021-12-24 22:16:15 -0500
committerConor Hoekstra <codereport@outlook.com>2021-12-24 22:16:15 -0500
commitc804b128cf740d95b244cd3fe15e86d0820ab51e (patch)
treeb9db7c3a5f93e6a83640f56bfd5decb9bbe8dbfe /challenge-033/paulo-custodio/python/ch-2.py
parent116add27d0d74360c7d4ad26b12d972657e51afa (diff)
parent6f518c687f743b68d3eeddedcf3d831aca20d4ec (diff)
downloadperlweeklychallenge-club-c804b128cf740d95b244cd3fe15e86d0820ab51e.tar.gz
perlweeklychallenge-club-c804b128cf740d95b244cd3fe15e86d0820ab51e.tar.bz2
perlweeklychallenge-club-c804b128cf740d95b244cd3fe15e86d0820ab51e.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-033/paulo-custodio/python/ch-2.py')
-rw-r--r--challenge-033/paulo-custodio/python/ch-2.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/challenge-033/paulo-custodio/python/ch-2.py b/challenge-033/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..c7ebd913b5
--- /dev/null
+++ b/challenge-033/paulo-custodio/python/ch-2.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python3
+
+# Challenge 033
+#
+# Task #2
+# Formatted Multiplication Table
+# Write a script to print 11x11 multiplication table, only the top half triangle.
+#
+# x| 1 2 3 4 5 6 7 8 9 10 11
+# ---+--------------------------------------------
+# 1| 1 2 3 4 5 6 7 8 9 10 11
+# 2| 4 6 8 10 12 14 16 18 20 22
+# 3| 9 12 15 18 21 24 27 30 33
+# 4| 16 20 24 28 32 36 40 44
+# 5| 25 30 35 40 45 50 55
+# 6| 36 42 48 54 60 66
+# 7| 49 56 63 70 77
+# 8| 64 72 80 88
+# 9| 81 90 99
+# 10| 100 110
+# 11| 121
+
+# print header
+print(" x|", end="")
+for col in range(1, 12):
+ print(f"{col:4d}", end="")
+print("")
+print("---+", "-"*(11*4), sep="")
+
+# print table
+for row in range(1, 12):
+ print(f"{row:3d}|", end="")
+ print(" "*(4*(row-1)), end="")
+ for col in range(row, 12):
+ print(f"{row*col:4d}", end="")
+ print("")