Question: Step 4 : Python only supports while loops, so endProgram must be initialized to ' no ' . create a variable called endProgram and set
Step : 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 : 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 The code should be as follows:
while endProgram no:
Step : The next step is to modify the loop control variable. This is done with a simple input statement such as:
endProgram inputDo you want to end the program? Enter yes or no:
Step : 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 and counter to Your code should look as follows:
totalBottles
todayBottles
counter
Step : Write a while loop with the condition of counter This code should look as follows:
while counter :
Step : 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 inputEnter number of bottles for today:
Step : Next, write the accumulator statement. This code should look as follows:
totalBottles totalBottles todayBottles
Step : 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
Step : Create a definition for calcPayment. This part should first reset totalPayout to This is done so that on multiple iterations of the program, totalPayout is reset to The second step is to calculate totalPayout as totalBottles times The last step is to return totalPayout. Your code should look as follows:
totalPayout
totalPayout totalBottles
Step : 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
