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

PYTHON QUESTION BANK

THEORY QUESTIONS:

1) Enumerate five distinctions among lists, tuples, sets, and


dictionaries, providing examples for each. Additionally, detail the
methods for adding and removing elements from each data
structure.
2) Give 5 examples of python inbuilt functions.
3) Explain Classes, Objects, Methods and Functions in detail.
4) What are libraries in python? Give examples of data manipulation
and visualization libraries.
5) Give syntax to open, write, read and close a file.
6) Compare List, Tuple, Set and Dictionary with example.
7) Explain different file opening mode, give any one example.
8) Write a note about Python Libraries.
9) Explain any five string functions and usage of it.
10) a) Differentiate between List, Tuple, Set, and Dictionary data
structures in Python. Provide a brief explanation of each and
highlight their key characteristics.
b) Explain the following list methods with an example.
append(), extend(), insert(), index(), sort().
11) Explain the key components and functionalities of Pandas, a
Python library used for data manipulation and analysis. Provide a
brief description of each component along with its primary
purpose.
12) Explain the concept of arithmetic operators and logical operators
in Python programming. Provide examples to illustrate the usage
of each type of operator.
13) Write the syntax of a for loop in Python, including its optional else,
break, and continue clauses. Provide a brief explanation of each
clause and its purpose.

CODES:

1) Write a Python program that calculates the factorial of a non-


negative integer entered by the user.
Example:
Input: Enter a non-negative integer: 5
Output: The factorial of 5 is 120.

2) Write a Python program that takes a list of numbers as input and


returns a new list containing only the even numbers from the
original list.
Input : Original list: [1, 2, 3, 4, 5, 6]

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.

You might also like