230k views
5 votes
Read the Python program below: num1 = int(input()) num2 = 10 + num1 * 2 print(num2) num1 = 20 print(num1) Question 1 When this program is executed, if the user types 10 on the keyboard, what will be displayed on the screen as a result of executing line 3? A. 30 B. 40 C. 10 + 10 * 2 D. 10 + num1 * 2

User Atina
by
4.9k points

1 Answer

7 votes

Answer

B. 30

Step-by-step explanation:

Assuming the code is written like this:

1. num1 = int(input())

2. num2 = 10 + num1 * 2

3. print(num2)

4. num1 = 20

5. print(num1)

Line 3 will print 30 when the number 10 is inputted at line 1.

Remember to use Order of Operations! :)

User Thimma
by
4.4k points