#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 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()
Комментарии:
1.
round(P*(1 (r/n))**(n/t),2)
? Вам не хватает аргументов вround()
.
Ответ №1:
Вот оно:
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)