0% found this document useful (0 votes)
17 views2 pages

Looping Test - 20 Marks

thank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Looping Test - 20 Marks

thank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Question Paper Subject: Python Programming

Topic: Looping in Python


Maximum Marks: 20
Time Allowed: 1 Hour
Instructions:
1. All questions are compulsory.
2. Write your answers clearly and concisely.
3. Marks for each question are indicated alongside.

Section A: Multiple Choice Questions (MCQs)


(Each question carries 1 mark)

1. Which of the following is a valid Python loop structure?


a) for loop
b) while loop
c) Both a and b
d) None of the above

2. What will be the output of the following code snippet?


for i in range(1, 5):
print(i, end=" ")
a) 1 2 3 4 5
b) 1 2 3 4
c) 1 2 3
d) None of the above

3. How can you terminate a loop in Python?


a) Using the stop keyword
b) Using the break statement
c) Using the exit function
d) None of the above

4. What does the continue statement do in a loop?


a) Exits the loop
b) Skips the remaining code for the current iteration
c) Repeats the loop from the beginning
d) None of the above

5. Which loop is used when the number of iterations is unknown?


a) for loop
b) while loop
c) Both a and b
d) None of the above

Section B: Short Answer Questions


(Each question carries 2 marks)

1. Write a Python program to print all even numbers between 1 and 20 using a for loop.
2. Write a Python program to print series 25 16 9 4 1 using a for loop.
3. What is an infinite loop? Write a Python code snippet to demonstrate it.
4. Differentiate between for and while loops in Python with examples.
5. Write a Python program using a while loop to calculate the sum of all integers from 1 to 10.
6. Python's range() function is often used in for loops. Describe the role of range() and write
a code snippet using it to print all even numbers from 10 to 50.
7. Write a Python program to print the following pattern using nested loops: (1 mark each)
a. 1 b. 5 4 3 2 1 c. 88888
22 4321 66666
333 321 44444
4444 21 22222
55555 1 00000

You might also like