Ask Question
2 August, 00:41

Write a Python program that uses a loop to calculate the total of a series of fractions as below. Inside the loop should be the two statements to (a) divide the numerator by the denominator and (b) add the result to a total. Display the total after the loop. Notice that the numerator increases by 1 after each iteration and the denominator decreases by 1. The lower and upper values in both cases are 1 and 30.

+1
Answers (1)
  1. 2 August, 04:36
    0
    numeratorValue = 1

    denominatorValue = 30

    count = 0

    while numeratorValue < = 30:

    difference = numeratorValue / denominatorValue

    count + = difference

    numeratorValue + = 1

    denominatorValue - = 1

    print (count)

    Explanation:

    Initialize the required variables and run a while loop until the numeratorValue is less than 30. Inside the while loop, calculate the difference by dividing the numeratorValue by denominatorValue. Add the value of difference variable to the count. Increment both the numeratorValue and denominatorValue. Lastly display the value of count.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a Python program that uses a loop to calculate the total of a series of fractions as below. Inside the loop should be the two ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers