[go: up one dir, main page]

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

Class 11-For Loop

class computer
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)
113 views2 pages

Class 11-For Loop

class computer
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

1. Write a for loop statement to print the following series 105,98,91,...........

2. Write a program to print sum of first 10 even numbers.

3. Find the output – if we give input as “Hello”

4. Write the output of the following program on execution if x = 50:


if x > 10:
if x > 25:
print ( 'ok' )
if x > 60:
print ( 'good' )
elif x > 40:
print ( 'average' )
else:
print ('no output')

5. Find the output of the following program segment:


for i in range(20, 30, 2):
print(i)

6. Write a function to display prime numbers below 30.

for num in range(2, 30):


for i in range(2, num):
if num % i == 0:
break
else:
print(num)

7. Consider the loop given below :


for i in range(10, 5, -3) :
print(i)
How many times will this loop run?
8. Predict the output of the following code fragments:
for x in [1,2,3]:
for y in [4, 5, 6]:
print (x, y)

9. Predict the output of the following code fragments:


c = 0
for x in range(10):
for y in range(5):
c += 1
print (c)

10. Only if statement can have an else clause. (True/False)

You might also like