【发布时间】:2017-03-18 16:42:35
【问题描述】:
用户应该能够输入他们想要做的时间表图表,然后程序将生成一个布局良好的图表。它不应该允许用户输入低于 1 的数字。它应该询问他们是否想在之后制作另一个时间表图表。请注意,您应该是嵌套循环。密切注意格式。
Example input/output
What timestables do you want to do? 5
1 2 3 4 5
----------------------------------
1 * 1 2 3 4 5
2 * 2 4 6 8 10
3 * 3 6 9 12 15
4 * 4 8 12 16 20
5 * 5 10 15 20 25
Do you want to do another timestables chart (y for yes)? y
What timestables do you want to do? -3
Not a valid number.
What timestables do you want to do? 7
1 2 3 4 5 6 7
--------------------------------------------------
1 * 1 2 3 4 5 6 7
2 * 2 4 6 8 10 12 14
3 * 3 6 9 12 15 18 21
4 * 4 8 12 16 20 24 28
5 * 5 10 15 20 25 30 35
6 * 6 12 18 24 30 36 42
7 * 7 14 21 28 35 42 49
Do you want to do another timestables chart (y for yes)? nooo
Hope you got smarter!
我正在尝试编写代码以使输出看起来像上面那样,但我完全不知道该怎么做。底部是我现在所拥有的,我想知道是否有人可以帮助我弄清楚如何编写这段代码。谢谢
column = int(input("What timestables do you want to do? "))
for x in range(1, column+1):
print(x, sep="\t")
【问题讨论】:
标签: python for-loop input charts