Analyze the following algorithm. Identify which steps demonstrate sequencing, selection, and iteration.
type your answers here:
Sequencing:
Selection:
Iteration:
Analyze the following code segment. Predict what is displayed when it runs.
- num1 β 2
- num2 β 4
- num3 β 5
- num1 β num2 + num3
- num3 β num1 + 5
- num2 β (num1 + num3) / 5
- DISPLAY(num1)
- DISPLAY(num2)
- DISPLAY(num3)
```python
Replace the ? with your answers
# Step-by-step tracking
num1 = 2
num2 = 4
num3 = 5
# after num1 β num2 + num3
num1 = ?
# after num3 β num1 + 5
num3 = ?
# after num2 β (num1 + num3)/5
num2 = ?
# Predicted Output
DISPLAY(num1) β ?
DISPLAY(num2) β ?
DISPLAY(num3) β ?
Instructions: Predict the value of result after executing the following code. Show your thought process and write your answer below. You can type and test this in VS Code.dev if you want.
num1 β 40
num2 β num1 / 2
num3 β 5 * num2 + 3
result β num2 MOD 3 * num1 + 4 - num3 / 2
DISPLAY(result)
```python
Write Your Answer Here
result = ______