Python 我如何舍入代码的输出?

Python 我如何舍入代码的输出?,python,Python,我是编程新手(昨天刚开始),我试着做一个计算器,当输入变量时,它会计算出数字。它工作得很好,但我希望这样做,以便代码最后的输出能够被舍入。我如何舍入代码的输出 print("What is the Initial Principal Value?") P = int(input()) print("What is the interest rate?") r = float(input()) print("What is the number

我是编程新手(昨天刚开始),我试着做一个计算器,当输入变量时,它会计算出数字。它工作得很好,但我希望这样做,以便代码最后的输出能够被舍入。我如何舍入代码的输出

print("What is the Initial Principal Value?")

P = int(input())
print("What is the interest rate?")
r = float(input())

print("What is the number of times interest is applied per time period")
n = int(input())

print("Finally, what is the number of time periods elapsed, this must be typed in terms of annual circumstances.")
t = int(input())
      
print(P*(1+(r/n))**(n/t))

round()
这是:

print("What is the Initial Principal Value?")

P = int(input())
print("What is the interest rate?")
r = float(input())

print("What is the number of times interest is applied per time period")
n = int(input())

print("Finally, what is the number of time periods elapsed, this must be typed in terms of annual circumstances.")
t = int(input())

result = round(P * (1 + (r / n)) ** (n / t), 2)
print(result)
round(P*(1+(r/n))**(n/t),2)
?您缺少
round()
中的参数。