Question: Step 4 : Python only supports while loops, so endProgram must be initialized to ' no ' . create a variable called endProgram and set

Step 4: Python only supports while loops, so endProgram must be initialized to 'no'. create a variable called endProgram and set it to 'no' such as:
endProgram ='no'
Step 5: The next step is to write a while statement with the condition of endProgram =='no':. The statement should be aligned with the statement in Step 4. The code should be as follows:
while endProgram =='no':
Step 6: The next step is to modify the loop control variable. This is done with a simple input statement such as:
endProgram = input('Do you want to end the program? (Enter yes or no): ')
Step 7: The first step should be to set your variables to values. In Python and most programming languages, in order for variables to be used, they need to have a starting value. This also allows for a reset of the variables when the program runs again. Set totalBottles and todayBottles to 0 and counter to 1. Your code should look as follows:
totalBottles =0
todayBottles =0
counter =1
Step 8: Write a while loop with the condition of counter <=7. This code should look as follows:
while counter <=7:
Step 9: Inside the while loop, write a statement that allows the user to enter the number of bottles for today. This code should look as follows:
todayBottles = input('Enter number of bottles for today: ')
Step 10: Next, write the accumulator statement. This code should look as follows:
totalBottles = totalBottles + todayBottles
Step 11: The last statement inside the loop should increment counter by one so the loop will end after seven iterations. This code should look as follows:
counter = counter +1
Step 12: Create a definition for calcPayment. This part should first reset totalPayout to 0. This is done so that on multiple iterations of the program, totalPayout is reset to 0. The second step is to calculate totalPayout as totalBottles times .10. The last step is to return totalPayout. Your code should look as follows:
totalPayout =0
totalPayout = totalBottles *.10
Step 13: The final part can display the total number of bottles returned and the total amount paid out. Your code should look as follows:
print 'The total number of bottles collected is', totalBottles
print 'The total paid out is $', totalPayout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!