19. Rewrite the following code after removing syntax error.
for i in range():
for J in range(1,i+1);
if i+j-1= =1:
x=1
x=x+1
print x
else i+j-2= =2:
x=2
x=x+1
print x
Answers
Explanation:
Section 5.2 The while Loop
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