Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Q1.

Write the output of the following

● for i in "python":

print (i)

● for i in range(5):

print(i)

● for i in range(10,15):

print(i)
Q2. Write a program to print first 10 natural number.

Q3. Write a program to print first 10 even numbers.

Q4. Write a program to print first 10 odd numbers.

Q5. Write a program to print first 10 even numbers in reverse


order.

Q6. Write a program to print table of a number accepted from


user.

Q7. Write a program to display sum of the digits of a number


accepted from the user.

Q8. Write a program to find the factorial of a number.

Q9.Convert the following while loop into for loop and also find
the output.

A.x=5
while(x<15):
print(x**2)
x+=3

B.a=7
b=5
while(a<9):
print(a+b)
a+=1
C. b=5
while(b<9):
print("H")
b+=1

D. b=15
while(b>9):
print("Hello")
b=b-2

E. x=15
while(x==15):
print("Hello")
x=x-3

Q.10 Find the output of the following:-

A.i=2
for x in range(i):
x+=1
print(x)
print(x)

B.i=2
for x in range(i):
x+=1
print(x)
print(x)

C.i=0
while i<3:
print(i)
i=i+1
print(0)

D.i=0
while i<3:
print(i)
i=i+1
print(0)

E.i=100
while i<57:
print(i)
i+=5

F.i=100
while i> 57:
print(i)
i+=5

Q.11 Write a program to display sum of odd numbers and even


numbers that fall between 12 and 37 (including both numbers)

Q.12 Write a program to display all the numbers which are


divisible by 11 but not by 2 between 100 and 500.

Q.13 Write a program that keep on accepting number from the user
until user enters Zero. Display the sum and average of all the
numbers.

Q.14 Write a program to print the first 20 natural numbers


except multiple of 2 & 3.

Q 15. Write a program to accept a number and check whether it is


a perfect number or not.

(Perfect number is a positive integer which is equal to the sum


of its divisors like divisors of 6 are 1,2,3, and sum of
divisors is also 6, so 6 is the perfect number)

You might also like