【发布时间】:2021-03-30 19:38:49
【问题描述】:
显示的数字从 10 开始并随机增加,直到达到 60。编写一个子程序来实现这一点。例如 10% 折扣。 24% 折扣。 48% 折扣。 60% 折扣。
这就是代码应该做的。这是我到目前为止写的代码。它只打印出 0% insted 的完整内容
import random
#subroutine to show discounts
def Percent(total, Num):
while total != 60:
total = total + Num
return total, Num
#main program
Num = random.randint(0,10)
total = 10
print(total,"% off")
ps 我对 python 很陌生,所以如果修复真的很明显,请不要吝啬 :)
【问题讨论】:
-
你永远不会打电话给
Percent。这是故意的吗? -
如果所有回复都没有解决您的问题,请您更新它以澄清缺少的内容吗?或者,查看what to do when someone answers your question 上的帮助页面指南。
标签: python random subroutine