![](/img/trans.png)
[英]Python - TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'? What am i doing wrong?
[英]I keep getting an error on Python, TypeError: unsupported operand type(s) for /: 'tuple' and 'int' What am I doing wrong?
#輸入
P = (float, input("Enter the starting principal: ") )
R = (float, input("Enter the annual interest rate: ") )
m = (int, input("How many times per year is the interest compounded? ") )
t = (float, input("For how many years will the account earn interest? ") )
#計算
#FV = P * ( 1 + ( (R/100) / m ) ) ** ( m * t)
FV = P * ( 1 + ( (R/100) / m ) ) ** ( m * t)
#輸出
print("At the end of ", t, "years. You will have $", format(FV, ",.2f") )
正確語法:
input_variable = float(input("some text"))
input_variable= int(input("some text"))
P = float(input("Enter the starting principal: ") )
R = float(input("Enter the annual interest rate: ") )
m = int(input("How many times per year is the interest compounded? ") ) )
t = float(input("For how many years will the account earn interest? ") )
FV = P * ( 1 + ( (R/100) / m ) ) ** ( m * t)
print("At the end of ", t, "years. You will have $", format(FV, ",.2f") )
float, input("bla bla bla"))
應該像float(input("bla bla bla")))
和int, input("bla bla bla"))
把它改成這樣: int(input("bla bla bla"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.