簡體   English   中英

我一直在 Python 上收到錯誤消息,TypeError: unsupported operand type(s) for /: 'tuple' and 'int' 我做錯了什么?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM