Professional Documents
Culture Documents
Python Question Bank
Python Question Bank
THEORY QUESTIONS:
CODES:
3) Write a code to find the sum of all the numbers present in list using
‘for’ or ‘while’ loop.
Example: list1 = [ 99, 89, 70, 22, 110]
4) Write a code to separate out even and odd numbers from a list and
store them in 2 different lists. Take list of any length including
even and odd numbers.
5) Write a code to find area of circle, square, rectangle, triangle and
trapezoid using classes and methods.
Formulas for each are:
Circle : 3.14*r*r (r = radius)
Square : s*s ( s = side of square)
Rectangle : l*b ( l = length, b = breadth)
Triangle : 0.5*b*h ( b = breadth, h = height)
Trapezoid : 0.5*(a+b)*h (a= upper side of trapezoid, b = lower side
of trapezoid, h= height of trapezoid).
6) Write Python program using “for loop” to calculate summation
and average of given numbers in the list.
e.g. input = [4, 6, 3, 5, 2, 8, 10, 11, 18] then it should output
summation = 48 and average = 8.
7) Write Python program using function for checking given number is
prime or not.
8) Create a calculator using classes and methods such that it can
perform addition, subtraction, multiplication and division
whenever called.
9) Write a code to calculate factorial of a number entered by a user.
10) Write a code to check whether the given number is prime or not,
take the number as input from the user.