Menu

(Solved) : 4 1 Equivalent Code Left Python Code Equivalent Flode Chart Previous Page Run Code See Dea Q44044431 . . .

4. 1. Equivalent code

On the left is the Python code equivalent of the Flode chartfrom the previous page.

If you run the code you will see that it deals with the loop inexactly the same way as the Flode chart did.

RUN THE CODE

Here’s the Flode chart as a reminder.

Start This is a counter variable. counter = 1 total = 0 This is our utility variable, total! If the condition is true, it

Next

counter = 1 # This is a ‘counter’ variable.
total = 0 # This is out utility variable ‘total’

while counter <= 10: # If the condition is true, it entersthe loop
total = total + counter # We add the current value of ‘counter’ to’total’
counter = counter + 1 # Here we add 1 to the counter.
# This is known as ‘incrementing’ the counter.
print(total) # And finally, we output ‘total’

Start This is a ‘counter’ variable. counter = 1 total = 0 This is our utility variable, ‘total! If the condition is true, it enters the loop counter <= 10 false ‘Final total : – total true total = total + counter We add the current value of ‘counter’ to ‘total’ counter = counter – 1 Here we add 1 to the counter. This is known total ‘incrementing’ the counter. And finally, we output total! Show transcribed image text Start This is a ‘counter’ variable. counter = 1 total = 0 This is our utility variable, ‘total! If the condition is true, it enters the loop counter

Expert Answer


Answer to 4. 1. Equivalent code On the left is the Python code equivalent of the Flode chart from the previous page. If you run th…

OR