工资计算应用程序代码不会运行

时间:2016-08-12 03:11:35

标签: python calculator

我正在尝试制作一个计算器应用程序,并以多种方式显示工资和工资,但我的功能不会运行。我没有收到任何错误消息,第一个'输入'有效,但之后似乎我的函数没有激活。我试图通过删除“if”和“elif”语句手动激活函数,然后只输入函数的名称。

know = input("Enter the letter for the category you know. if you know how much you earn per hour type '1'. if you know how much you earn per week type '2'. if you know your salary type '3'")

def wage():
a = input(int("How much do you earn per Hour?"))
b = input(int("How many hours do you work per day?"))
c = input(int("How many days do you work per week?"))
hour = ("you earn £",a, "per hour")
day = ("you earn £",a*b, "per day")
week = ("you earn £",day*c, "per Week")
year = ("your salary is £",week*52, "per year")
print (hours)
print (day)
print (week)
print (year)

def week():
a = input(int("How much do you earn per week?"))
b = input(int("how many hours do you work per day?"))
c = input(int("how many days do you work per week"))
hour = ("you earn £",(a/c)/c, "per hour")
day = ("you earn £",hour*b, "per day")
week = ("you earn £",day*c, "per week")
year = ("your salary is £",week*52, "per year")
print (hours)
print (day)
print (week)
print (year)

def year():
a = input(int("how much do you earn per year?"))
b = input(int("how many hours do you work per day?"))
c = input(int("how many days do you work per week"))
hours = ("you earn £",((a/52)/7)/b, "per hour")
day = ("you earn £",hour*b, "per day")
week = ("you earn £",day*c, "per week")
year = ("your salary is £",week*52, "per year")
print (hours)
print (day)
print (week)
print (year)

if know == "1":
wage
elif know == "2":
week
elif know == "3":
year
else:
print("I'm Confused")

如果有人可以帮助我,我将不胜感激

1 个答案:

答案 0 :(得分:0)

将if-else中的wageweekyear更改为wage()week()year()以实际执行功能:

if know == "1":
    wage()
elif know == "2":
    week()
elif know == "3":
    year()
else:
    print("I'm Confused")