我正在做一个关于通过函数传递参数的项目。我的问题是我正在编写一个程序,根据年龄和交通违规给出收费金额。这是我当前的代码:
print("Use this program to estimate your liability.")
def main():
user_name()
age()
violations()
risk_code()
#Input#
#Def for name
def user_name():
user_name = print(input("What is your name?"))
#Def for age
def age():
age = int(input("What is your age?"))
#Def for traffic violations (tickets.)
def violations():
violation = print(input("How many traffic violations (tickets) do you have?"))
#Process#
def risk_code(violation):
if violation == 0 and age >= 25:
risk = "None"
cost = int(275)
#How many tickets to indicate risk code (therefore risk type)
# Age + traffic violations (tickets) = risk code
# Age + Traffic violations + Risk Code = Price
#Output#
#Def for customer name
# Def for risk output
# Def for cost
main()
如果我选择我的年龄为 25 岁,我希望程序显示客户欠款多少,并且违规行为为零。问题是我不断收到位置参数错误。我对这意味着什么有点困惑。任何人都可以提供帮助/示例吗?