54,049 views
11 votes
11 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 Amir Jalali
by
2.4k points

1 Answer

19 votes
19 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 PLui
by
3.2k points