Understanding a.mini.TRACS Program Execution

Slide Note
Embed
Share

Explore the program execution of a.mini.TRACS through step-by-step analysis, including variable values and output at each stage. Witness how the program progresses and learn the sequence of statements executed. Follow the journey of the counter variable and discover what is printed at each iteration.


Uploaded on Oct 03, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. A mini TRACS

  2. Variables Table counter = 1 while counter < 4: print("Happy days") What is printed? counter = counter + 1 print( End of program )

  3. Variables Table Step 1: Draw round all expressions counter = 1 while counter < 4: print("Happy days") What is printed? counter = counter + 1 print( End of program )

  4. Step 2: Draw arrows to show the order the statements are executed Variables Table counter = 1 FALSE while counter < 4: TRUE print("Happy days") What is printed? counter = counter + 1 print( End of program )

  5. Step 3: Work through the program showing variables and output Variables Table counter counter = 1 FALSE while counter < 4: TRUE print("Happy days") What is printed? counter = counter + 1 print( End of program )

  6. Step 3: Work through the program showing variables and output Variables Table counter counter = 1 while counter < 4: 1 FALSE TRUE print("Happy days") What is printed? counter = counter + 1 print( End of program )

  7. Step 3: Work through the program showing variables and output Variables Table counter counter = 1 1 FALSE TRUE while counter < 4: 1 TRUE print("Happy days") What is printed? counter = counter + 1 print( End of program )

  8. Step 3: Work through the program showing variables and output Variables Table counter counter counter = 1 1 1 FALSE while counter < 4: 2 TRUE print("Happy days") What is printed? counter = counter + 1 Happy days print( End of program ) Working out area counter = counter + 1 counter = 1 + 1 counter = 2

  9. Step 3: Work through the program showing variables and output Variables Table counter = 1 counter 1 FALSE TRUE while counter < 4: 2 2 TRUE print("Happy days") What is printed? counter = counter + 1 Happy days print( End of program )

  10. Step 3: Work through the program showing variables and output Variables Table counter counter counter = 1 1 1 FALSE while counter < 4: 2 TRUE 3 print("Happy days") What is printed? counter = counter + 1 Happy days print( End of program ) Happy days Working out area counter = counter + 1 counter = 2 + 1 counter = 3

  11. Step 3: Work through the program showing variables and output Variables Table counter counter = 1 1 FALSE TRUE while counter < 4: 3 2 3 TRUE print("Happy days") What is printed? counter = counter + 1 Happy days print( End of program ) Happy days

  12. Step 3: Work through the program showing variables and output Variables Table counter counter counter = 1 1 1 FALSE while counter < 4: 2 TRUE 3 print("Happy days") 4 What is printed? counter = counter + 1 Happy days print( End of program ) Happy days Happy days Working out area counter = counter + 1 counter = 3 + 1 counter = 4

  13. Step 3: Work through the program showing variables and output Variables Table counter counter counter = 1 1 1 FALSE FALSE while counter < 4: 4 2 TRUE 3 print("Happy days") 4 What is printed? counter = counter + 1 Happy days Happy days print( End of program ) Happy days

  14. Step 3: Work through the program showing variables and output Variables Table counter counter counter = 1 1 1 FALSE FALSE while counter < 4: 2 TRUE 3 print("Happy days") 4 What is printed? counter = counter + 1 Happy days print( End of program ) Happy days Happy days End of program

  15. Now for another example

  16. Variables Table def input_name(): name = input("What is your name? ") counter = 1 What is printed? (Output) while counter <= 4: print("Hello" + name) Working out area counter = counter + 1 print("Goodbye "+ name) Step 1: Draw round all expressions Step 2: Draw arrows showing the order in which the statements will be executed Step 3: Work through the program filling in the variables table and the Output box

Related


More Related Content