編寫一個程序來打印商和餘數,但是在任何地方都可以將quotientProblem函數改爲一個名爲quotientString的函數,它只返回字符串而不是直接打印字符串。具有主函數將每次調用的結果打印到quotientString函數。在商和剩餘的輸出中顯示'None'
def value():
a=int(input("Enter a number: "))
b=int(input("Enter next number: "))
z=print("When",a,"is divided by",b,"the remainder is",a%b,"and the quotient is",a//b,".")
print (division(a,b,z))
def division(x,y,z):
return z
value()
當我執行
>>>Enter a number: 5
>>>Enter next number: 3
When 5 is divided by 3 the remainder is 2 and the quotient is 1 .
None
這裏None
持續顯示。
5除以3時餘數爲2,商爲1。我希望這個顯示。 –