我是python的新手,并且通常是编程的,所以这可能非常简单,但是在为minPayment定义函数的代码行的末尾,我始终遇到此语法错误。我看不到任何问题...到目前为止是程序。
习题1:信用卡余额计算器
print 'Month 1'
OutstandingBalance = raw_input(float('enter your balance'))
AnnualInterestRate = raw_input(float('enter rate as a decimal(%/100)'))
MinimumMonthlyPaymentRate = raw_input(float('enter minimum monthly payment rate as a decimal(%/100)'))
def minPayment:
minPayment = MinimumMonthlyPaymentRate * OutstandingBalance
print 'minimum payment='minPayment
return minPayment
def accIntrst:
accIntrst = (AnnualInterestRate/12.0) * OutstandingBalance
print 'accrued interest = 'accIntrst
return accIntrst
def balPaid:
balPaid = accIntrst - minPayment
print 'balance paid = 'balPaid
return balPaid
def remBal:
remBal = OutstandingBalance - balPaid
print 'remaining balance = 'remBal
return remBal
任何反馈,不胜感激!
最佳答案
在函数中添加括号。 Python语法要求如此。
因此,代替def minPayment:
,而写def minPayment():
。