Question: Solve this feedback error. Change my python code to solve this. Please look at picture below. Question Goal: Learn to use loops together with variables
Solve this feedback error.
Change my python code to solve this.
Please look at picture below.
Question
Goal: Learn to use loops together with variables to accumulate a result.
Assignment Assume that is assigned a positive integer. Write code using the while loop to assign to total the sum of the firt whole numbers as followe
If the number is even, halve and add its
If the number is odd, add it
For example, if is total will be
Reminder. Whole numbers are dots and so onn
total i while i nmathrm :
if i : # Check if the number is even
total t i # Halve the even number and add to total
else: # The number is odd
total t i # Add the odd number to total
i t # Increment the counterprintfThe total is: total
More information
The total iss
Feedback:
P The expected value for 'total' was but actual is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
