0% found this document useful (0 votes)
9 views3 pages

For Loop Revision 2

The document contains a graded sheet for practicing Python for loops, including multiple choice questions, coding tasks, and output prediction exercises. It covers the purpose of for loops, correct syntax for printing numbers, and various coding challenges such as displaying squares of numbers, countdowns, and birthday announcements. The document aims to assess understanding and application of for loops in Python programming.

Uploaded by

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

For Loop Revision 2

The document contains a graded sheet for practicing Python for loops, including multiple choice questions, coding tasks, and output prediction exercises. It covers the purpose of for loops, correct syntax for printing numbers, and various coding challenges such as displaying squares of numbers, countdowns, and birthday announcements. The document aims to assess understanding and application of for loops in Python programming.

Uploaded by

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

Graded Sheet - FOR Loop Practise

1. Multiple Choice Questions


Read the following questions carefully and select the correct answer from the options
provided
1. What is the purpose of a for loop in Python?
a) To define a function.
b) To repeat a block of code multiple times.
c) To take user input.
d) None of the above.
2. Which statement correctly prints the numbers 0, 1, 2, 3, 4?
a) for i in range(1, 5,1): print(i)
b) for i in range(0, 5, 1): print(i)
c) for i in range(1, 6,1): print(i)
3. What will the following code do?
for i in range(5, 10, 2):
print(i)
a) Print numbers 5, 7, and 9.
b) Print numbers 5 and 10.
c) Print numbers 5, 6, 7, 8, 9, and 10.
d) Produce an error.

2. Coding Question
Write a Python program that takes a number from the user and prints the square of the
number for 5 iterations/times using a for loop.
Example Output:
Input: 3
Output:
9
9
9
9
9
3. Find the Output(Also try on GDB compiler to check your answer)
Find the output of the following code snippets and write it in the space provided. [8]

Code Output

for i in range(1,3,1):
print(i)

for i in range(2, 7, 2):


print(i)
print(“hello”)

for i in range(5, 0, -1):


print(i)

for i in range(1, 6,1):


print(i**2)

for i in range(0, 11, 4):


print(i)

for i in range(1, 10, 3):


print(i)

for i in range(2,4,1):
print("Python")

for i in range(3, 10, 2):


print(i)
Write python program for following questions using FOR Loop:

a) Write a program to display numbers from 1 to 10 on a countdown board for


an event.

b) Write a program to print all even numbers between 100 and 500.

c) Create a program to accept the name of your best friend and display it 15
times on the screen as a birthday reminder announcement.
Eg : if name is “John” then print “Happy birthday John” 15 times

d) WAP to accept score of the student out of 10. If the score is above 7, display
“Well done!” 20 times to celebrate their achievement. If the score is 7 or
below, display “Keep practicing!” once.

e) Write a program to display a countdown for a rocket launch, starting from 10


and ending at 1, followed by "Liftoff!"
Hint: Use range(10, 0, -1) for the countdown and print "Liftoff!" after the
loop.

You might also like