Sei sulla pagina 1di 1

G D GOENKA PUBLIC SCHOOL, LUCKNOW

Class XI Computer Science with Python


Worksheet – Conditional and Iterative Statements
1. What are the two categories of Python loops?
2. What is a statement? How many types of statements are there in Python?
3. What is the need for selection and looping constructs?
4. Correct the following code fragment:
If (x=1)
A=200
else
A=10
5. What is the use of range function? What would range(1,10) return?
6. What is the output of the following code:
for a in range(10,1):
print (“Thank you”)
7. What is the output of following code?
for a in range (1,6):
for b in range (1,a):
print (“@”, end=’,’)
print ( )
8. Numbers in the form 2n – 1 are called Mersenne Numbers, e.g., 21 -1=1, 22-1=3, 23-1=7
Write a Python script that displays first ten Mersenne numbers.
9. Number Guessing Game – This program generates a random number between 1 and 100 and
continuously asks the user to guess the number, giving hints along the way.
10. Write a Python Script to input two numbers and print their LCM (Least Common Multiple) and GCD
(Greatest Common Divisor).
11. Write a Python script to calculate sum of following series:
S= (1) + (1+2) + (1+2+3) +……….+ (1+2+3+……+n)
12. Write a Python script to print the following pattern:
54321
5432
543
54
5

Potrebbero piacerti anche