What will be the output after the following code fragment is executed.
(a) c= 2*3 /4 + 5-6/7 *8
print(c)
(b) print(14//4, 14%4)
Answers
5.1 How many times will the following code print "Welcome to Python"?
count = 0
while count < 10:
print("Welcome to Python")
count += 1
A. 8
B. 9
C. 10
D. 11
E. 0
5.2 What is the output of the following code?
x = 0
while x < 4:
x = x + 1
print("x is", x)
A. x is 0
B. x is 1
C. x is 2
D. x is 3
E. x is 4
5.3 Analyze the following code.
count = 0
while count < 100:
# Point A
print("Welcome to Python!")
count += 1
# Point B
# Point C
A. count < 100 is always True at Point A
B. count < 100 is always True at Point B
C. count < 100 is always False at Point B
D. count < 100 is always True at Point C
E. count < 100 is always False at Point C
5.4 How many times will the following code print "Welcome to Python"?
count = 0
while count < 10:
print("Welcome to Python")
A. 8
B. 9
C. 10
D. 11
E. infinite number of times
5.5 What will be displayed when the following code is executed?
number = 6
while number > 0:
number -= 3
print(number, end = ' ')
A. 6 3 0
B. 6 3
C. 3 0
D. 3 0 -3
E. 0 -3