For Loop Revision 2
For Loop Revision 2
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,4,1):
print("Python")
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.