Check your understanding of the previous reading: evaluating expressions versus printing them, and the interactive-console (REPL) concept.
Evaluate the following expression:
(1 + 2) * (3 + 4)
1 + 2 evaluates to 3, and 3 + 4 evaluates to 7. Then 3 * 7 evaluates to 21.
What will happen when the following code is run as a program, the normal way (not evaluated on an interactive console)?
400 / 2
Select one answer, then check.
400 / 2 is evaluated to 200.0, but since there is no print, the result is thrown away and nothing appears in the console.400 / 2 is completely valid Python syntax — it's just an expression.print statement, running this as a saved program does not show the result anywhere.Think back to "Throwing Away Results" in the reading: an expression on its own line is still evaluated, but its value only reaches the console through print.
Now imagine typing the very same expression directly into an interactive console (a REPL), instead of running it as a program. What happens?
400 / 2
Dodona itself has no interactive console — this checks the concept from the reading. Select one answer, then check.
print needed.This is the same expression as the previous question, but evaluated on an interactive console instead of run as a program. What does the "Seeing the Results" section say a console does differently?
Which of the following statements are true about the interactive console?
Select every true statement, then check.
print to show it. An input prompt is written to the console too, but that is the prompt, not the value of an expression.print.print appears.print calls at all still runs from start to finish; it simply produces no console output.Two of the four statements are true. Think about which side (program vs. interactive console) actually needs print to show something.
Match each term to its definition:
| Term | Definition |
|---|---|
| Console | |
| Evaluate | |
| Shell | |
| Run | |
Two of the five are near-synonyms, and two are the actions you take.
The matches:
| Term | Definition |
|---|---|
Console | The interactive area of a programming environment where output is printed and input is taken from the user. |
Evaluate | To execute an expression and compute the result. |
Shell | A synonym for the console. |
Run | To execute one or more lines of code, possibly with some kind of output (but that is not guaranteed). |
Print | To put text onto the console. |
That's five things to get right here, one per term.