Write a function called myseries with no inputs myseries wh
Write a function called myseries with no inputs myseries () which returns the total value of the following series: 1/30 + 2/29 + 3/28 + ... + 29/2 + 30/1
Solution
# below is the defination of function myseries()
def myseries():
denominator = 30 # Denominator of series starting from 30
sum = 0.0
for numerator in range(1,31): # Numerator range is 1...30 and hence it should start from 1 and stop @30
sum += (float(numerator)/denominator) # calculating individual fraction term of series and adding them
denominator -= 1 # decrementing denominator by 1
return sum # returning final value of series
print \"total value of series =\",myseries() # calling myseries function
