CS 115 Lab 1, Part A: Experimenting with print statements
and the Online Python Tutor
Back to Lab 1
Summary
In this part of the lab, you will type print statements into an online Python tutor to see how they work.
Instructions
- Go to your browser tab with the Lab 1 writeup in Moodle, and answer Question 4 (and ONLY
Question 4). Vocabulary is not the main point of this class, but it's important to have a
common language to talk about these new concepts.
Feel free to ask the instructor for
help or search the internet -- whatever it takes to help you understand what all of these words
mean.
Click the "Check" button to check your answers until you get full credit for the
question.
- There is an online Python 3 tutor that
allows you to watch a program execute step by step. Open that website in a new tab and enter the following Python code in the box labeled
"Write your Python code here:"
print('Hello!')
print('Hi!')
Then click "Visualize execution."
- You should now see your code at the top left of the window. A red arrow points to the next instruction that will be executed.
Try clicking the "Forward" button once. Verify that you can see the following:
- The output of the first statement will be displayed in the window just below your program.
- The red arrow has moved on to the next statement to be executed.
- A faint green arrow points to the statement that you just executed.
- Each time you click "Forward", the next statement will be executed and the output will be updated. Try it!
- Click the "Edit code" link just below your program, and replace your old code with the following code:
print('Hello!', 'Hi!')
Visualize this program.
- Try to answer Question 5 in your Moodle writeup without using the visualizer.
If you get stuck, you can use the visualizer to see
exactly what each statement will print. Click the "Check" button to check your answers.
- Answer Question 6 in your writeup. Almost all of your writeups will have a question like this.
There are two reasons why:
- Writing about technical topics is an important skill, and it helps solidify your understanding of
the material.
- Your explanations help the course staff catch minor misunderstandings that you may have -- before they cause you
serious problems.
- Continue to Part B.