Ifelse and loops in Python Quiz

 

How many times will the loop run?
python
CopyEdit
for i in range(1, 6):
print(i)

 
 
 
 

 

What is the correct syntax for an if statement in Python?

 
 
 
 

 

What will happen if the loop condition is never False?

 
 
 
 

 

What is the purpose of the elif statement?

 
 
 
 

 

What will be the output of the following code?
x = 10
if x > 5 and x < 15:
print("Valid")

 
 
 
 

 

What will range(5) generate?

 
 
 
 

 

What will be the output of the following code?
x = 5
if x > 5:
print(“A”)
elif x == 5:
print(“B”)
else:
print(“C”)

 
 
 
 

 

Which loop is best when the number of iterations is unknown?

 
 
 
 

 

How do you check if a number is odd in Python?

 
 
 
 

 

What will be the output of the following code?
x = 10
if x > 5:
if x < 15:
print("Within range")

 
 
 
 

5 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments