Quiz on Loops in Python
Q.1. A while loop in Python is used for what type of iteration?
Q.2. What is the output of following program?
for i in range(10):
if i%2==0:
print(i,end=" ")
Q.3. What is the output of following program?
x = 5
while x!=0:
print(x,end="")
x+=1
Q.4. What will be the total number of iterations for the following snippet of code?
for i in range(3):
for j in range(4):
for k in range(5):
#Code
Q.5. What will be the value of n after code execution?
n = 10
for i in range(10):
for j in range(2, 10, 1):
if n % 2 == 0:
continue
n += 1
n+=1
else:
n+=1
Q.6. What is the number of lines of elements in output?
l1 = [1, 2]
l2 = [3, 4]
for x in l1:
for y in l2:
print(x,y)
Q.7. Which loop is not present in python?
Q.8. A loop becomes infinite loop if a condition never becomes _____
Q.9. How the body of the loops is identifiable in Python?
Q.10. What will be the total Number of iterations for the following code?
for i in range(5):
break
for j in range(3):
for k in range(2):
#Code
Q.11. What is the output of following program?
l = ["Car","Bike","Ship","Plane"]
for i in l:
print(i,end=" ")
Q.12. Which type of loop can be used to perform the following iteration:
You choose a positive integer at random and then print the numbers
from 1 up to and including the selected integer
You choose a positive integer at random and then print the numbers
from 1 up to and including the selected integer
Q.13. Which letter won't be printed?
for c in 'Python':
if c == 'h':
continue
print('Character: ' + c)
Q.14. Which letter won't be printed?
nums = [6,-3,2,-8,-9]
out = []
for num in nums:
if num < 0:
continue
else:
out.append(num)
print(out)
Q.15. What is the output of following code?
c = "HelloWorld"
for i in c:
print(i,end=" ")
Instructions:-
- This Quiz is based on Loops in Python
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP