【发布时间】:2020-06-13 09:01:25
【问题描述】:
我正在设计一个计算你的薪水的程序。它涉及多个函数,我需要做的是从调用它们的顺序循环所有这些函数。这是我没有循环的代码:
def showIntro():
intro = print('Hello! I will take your input and calculate your
weekly paycheck before
taxes.')
showIntro()
def get_rate():
rate = float(input('Enter hourly rate: '))
return rate
def get_hours():
hours = float(input('Enter hours worked: '))
if hours >= 41:
print('Your base hours including overtime is: ' , hours)
if hours <= 40:
print('Your hours entered were: ' , hours)
return hours
def get_paycheck(rate , hours):
paycheck = rate * hours
if hours >= 41:
print('Your weekly paycheck with over time is: ' , rate * hours)
if hours <=40:
print('Your weekly paycheck is: ' , rate * hours)
return (rate , hours)
rate = get_rate()
hours = get_hours()
get_paycheck(rate,hours)
结束代码
我如何循环它,让它回到 showIntro() 并重复自己。
【问题讨论】:
-
了解 for 和 while 循环:tutorialspoint.com/python/python_loops.htm
-
试一试阅读文档。
标签: python python-3.x function loops