0% found this document useful (0 votes)
33 views8 pages

Python Exam Sample Questions & Solutions

The document contains a series of Python programming exercises for students, focusing on sequential, conditional, and loop programming. Each exercise includes a description of the task, sample code, and expected output. The tasks range from basic input/output operations to more complex calculations and loops, aimed at enhancing students' coding skills in Python.

Uploaded by

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

Python Exam Sample Questions & Solutions

The document contains a series of Python programming exercises for students, focusing on sequential, conditional, and loop programming. Each exercise includes a description of the task, sample code, and expected output. The tasks range from basic input/output operations to more complex calculations and loops, aimed at enhancing students' coding skills in Python.

Uploaded by

saiprabhav143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

DELHI PUBLIC SCHOOL

VIII ANNUAL EXAM ICT -PRACTICAL SAMPLE QUESTIONS & SOLUTIONS

SEQUENTIAL PROGRAMMING

Practice and Execute the Python code of the following:


1. Write a Python code to input your name and age and print them

2. Write a Python code to input two numbers and perform all arithmetic
operations (addition, subtraction, multiplication, division, floor division,
exponent)
3. Write a Python code to input Principle, Rate percent and No. of years and
calculate Simple Interest
4. Write a Python code to input length and breadth from the user and

calculate area and perimeter of a rectangle (Area=l*b,


Perimeter=2*(l+b))

5. Write a Python code to input your father’s name and mother’s name and
add the string and print them
6. Write a Python code to input base and height and calculate the area of a
triangle. (Area=0.5*b*h)
CONDITIONAL PROGRAMMING

7. Write a Python code to get the input of age and check eligible for voting

8. Write a Python code to read a number and print whether a number is positive or
negative
9. Write a Python code to read a number and print the smaller of two numbers.

10. Write a Python code to read three numbers and print the largest among the three
numbers:

11. Write a Python code to read the total percentage and print the grades as per the following (refer book)

Percentage Grade

More than 90 and less than or equal to 100 A

More than 75 and less than or equal to 90 B

More than 60 and less than or equal to 75 C

More than 50 and less than or equal to 60 D

Less than or equal to 50 D2


FOR…. LOOP

12. Write a python program using loops to display the table of 2


CODING:
#Python program to display the table of 2 using for loop
n=int(input("Enter no :"))
for x in range(1,11):
print(n,"X",x,"=",n*x)
OUTPUT:
2X1=2
2X2=4
.
.
2 X 10 = 20

13. Write a python program using loops to display your name 5 times
CODING:
#Python program to display your name 5 times
n1=input("Enter your name :")
for i in range(1,6):
print(n1)
OUTPUT:
Enter your name :Tarika
Tarika
Tarika
Tarika
Tarika
Tarika

14. Write a python program using loops to display the square of numbers from
1 to 10
CODING:
#To display the square of numbers from 1 to 10
for i in range(1,11):
print("Square of ",i," is ",i*i) #i**2
OUTPUT:

Square of 1 is 1
Square of 2 is 4
Square of 3 is 9
Square of 4 is 16
Square of 5 is 25
Square of 6 is 36
Square of 7 is 49
Square of 8 is 64
Square of 9 is 81
Square of 10 is 100

15. Write a python program using loops to display the even numbers from 20
to 35
CODING:
#To display the even numbers from 20 to 35
for a in range(20,35,2):
print(a)

OUTPUT:
20
22
.
.
32
34

16.Write a python program using loops to display the odd numbers from 91 to
1. (reverse order)
CODING:
#To display the odd numbers from 91 to 1. (reverse order)
for a in range(91,0,-2):

print(a)
OUTPUT:
91
89
.
.
1
WHILE LOOP

17.Write a python program using while loop to print 10 multiples of a number


entered by the user
CODING:
#Python program to print 10 multiples of a number
n=int(input("Enter a number "))
i=1
while i<=10:
print(n," x ",i," = ", n*i)
i+=1

OUTPUT:
Enter a number 5
5 x 1 = 5
5 x 2 = 10
.
.
5 x 10 = 50

18.Write a python program using while loop to display your school name 5
times
CODING:
#Python program to display your school name 5 times
a=1
while(a<=5):
print("Delhi Public School")
a+=1
OUTPUT:
Delhi Public School
Delhi Public School
Delhi Public School
Delhi Public School
Delhi Public School

19. Write a python program using while loop to display the square of the
number from 20 to 10
CODING:
#Python program to display the square of the number from 20 to 10
x=20
while(x>=10):
print("The square of ",x, "is ",x*x)
x-=1
OUTPUT:

The square of 20 is 400


The square of 19 is 361

The square of 10 is 100

20. Write a python program using while loop to display the series of the
number 1,5,9,13,17,21,..100.
CODING:
#Python program to display the series of the number 1,5,9,13,17,21,..100.
x=1
while(x<=100):
print(x,end=",")
x+=4
OUTPUT:
1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,

21. Write a python program using while loop to display the odd numbers from
51 to 1. (reverse order)
CODING:
#Python program to display the odd numbers from 51 to 1. (reverse order)
p=51
while(p>=1):
print(p, end=",")
p-=2
OUTPUT:
51,49,…..1

You might also like