Answer to Question #225201 in Python for Reclimet

Question #225201

Sum of N terms in Harmonic series


This Program name is Sum of N terms in Harmonic series. Write a Python program to Sum of N terms in Harmonic series, it has two test cases


The below link contains Sum of N terms in Harmonic series question, explanation and test cases


https://docs.google.com/document/d/1kZEEzRlzAo_HT0I9HineNAMs_3PwlU2_/edit?usp=sharing&ouid=104486799211107564921&rtpof=true&sd=true


We need exact output when the code was run

1
Expert's answer
2021-08-11T06:26:43-0400
def sum1(x):
    col = 1
    answer = 0.0
    for col in range(1, x+1):
        answer = answer + 1/col
    return answer
 
# Testing Code
print("Sample Input 1\n 5")
n = 5
print("Sample Output 1\n", round(sum1(n), 2))
print("\nSample Input 2\n 3")
n = 3
print("Sample Output 2\n", round(sum1(n), 2))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS