More Python Tutor examples
-
Correctly passing input to a function and getting a result back.
What will the program print? Visualize it and see! How many times does
the program counter (the red arrow on the left) move up instead
of down?
-
Incorrect data in or out of function.
Where does this program crash, and why? How can you fix it so it correctly
prints the percentage?
-
Building a dictionary and using a for loop on it.
What is the data type of all the variables in main()?
- Missing key in a dictionary.
When you try and run this one, it says "key error - Pluto". What is the problem? Can you fix it? How about if you want to leave Pluto in the list; can you
change the code so that it checks to see if a key is in the dictionary before
trying to get the data out?
-
Conversion error.
What line does this program crash on and why?
Put the offending line in the block
under the try in a try-except construction.
What would be a good alternate behavior to put in the block under the
except?