我正在編寫一個腳本,要求用戶輸入兩個數字作爲時間表的最大值,然後使用我已經定義的兩個函數繪製表格。但是,我不知道如何將所有東西結合在一起來完成這個任務。以下是我有:使用已定義函數的腳本
print("What is the maximum value for the first factor?")
number1 = input()
print("What is the maximun value for the second factor?")
number2 = input()
print("Here is your times table:")
def times_table(times,factor):
"""takes two positive integers and returns a list of lists
int, int -> list of lists"""
table = [[0]*(factor+1)]
for i in range(1,times+1):
table.append(list(range(0,i*factor+1,i)))
return table
def print_table(listx):
"""takes a list of lists of numbers and displays them on the screen
list of numbers -> numbers"""
for x in listx:
for y in x:
print('{0:<10}'.format(y), end='')
print()
這是否在腳本的末尾? – holaprofesor
是的,在函數定義之後 – ODiogoSilva