Не важно, я вижу, что вы хотели все это в rms()
от прочтения. Я полагаю, что вы хотели, чтобы все в rms()
было осторожным со своими отступами, чтобы некоторые части вашей функции не выходили за пределы функции, хотя это работает, но не уверен, что вы желаемый результат, хотя.
import math
def rms():
print("This program will calculate the RMS of your values.")
print()
n = int(input("Please enter the number of values you want calculated: "))
total = 0.0
for i in range(n):
x = float(input("Enter a desired values:"))
total = total + math.sqrt(x)
print("\nThe Root Mean Square is:", math.sqrt(total/n))
rms()
(xenial)vash@localhost:~/python/stack_overflow$ python3.7 rms.py
This program will calculate the RMS of your values.
Please enter the number of values you want calculated: 3
Enter a desired values:10
Enter a desired values:3
Enter a desired values:2
The Root Mean Square is: 1.4501197686295146