我正在设计一个程序来计算你的薪水。它涉及多个函数,我需要做的是按照调用顺序循环所有这些函数。以下是我的无循环代码:
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()并重复自身
您可以将所有函数调用放入
while
循环中相关问题 更多 >
编程相关推荐