0% found this document useful (0 votes)
4 views

python question pAPER

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

python question pAPER

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Section A: (10 × 2 = 20 Marks)

Answer any ten of the following questions.


Section A: (10 × 2 = 20 Marks)
Answer any ten of the following questions.
(Each question carries 2 marks)
1. What is the difference between Python 2.x and
Python 3.x?
2. Define the term list in Python. How is it different
from a tuple?
3. What are f-string literals in Python? Give an
example.
4. What is the use of the pass statement in Python?
5. What is the output of the following Python code:
python
Copy code
print(2 ** 3)
6. Define a function in Python. How do you pass
arguments to it?
7. What is the difference between local and global
variables in Python?
8. What does the range() function do in Python?
9. Explain the concept of inheritance in Python.
10. What is the difference between deep copy and
shallow copy?
11. How do you handle exceptions in Python?
Give an example.
12. What is the difference between while loop and
for loop in Python?
Section B: (5 × 6 = 30 Marks)
Answer any five of the following questions.
(Each question carries 6 marks)
1. Write a Python program to check whether a
number is even or odd.
2. What is a dictionary in Python? Write a program
to add, remove, and display items in a dictionary.
3. Write a Python program to find the factorial of a
number using recursion.
4. Write a program to reverse a string in Python
without using the built-in function.
5. Explain file handling in Python. Write a program
to read from and write to a file.
6. What are lambda functions in Python? Write a
Python program to add two numbers using a
lambda function.
7. Write a Python program that accepts a list of
integers and prints the sum and average of the list.

Section C: (3 × 10 = 30 Marks)
Answer any three of the following questions.
(Each question carries 10 marks)
1. Write a Python program to create a class called
Student that includes:
o Attributes: name, roll_number, and

marks.
o Methods to:
 Accept the student's details.

 Display the student's details.

o Create an instance of the class and display the

student’s information.
2. Explain the object-oriented programming (OOP)
concepts in Python. Write a Python program to
demonstrate inheritance by defining a Person
class with attributes like name and age, and an
Employee class that inherits from Person and adds
a salary attribute.
3. Write a Python program that accepts a sentence
from the user and:
o Count the number of vowels in the sentence.

o Reverse the sentence and display it.

4. Write a Python program to find the GCD


(Greatest Common Divisor) of two numbers
using recursion.
5. Write a Python program that:
o Accepts a number from the user and checks if

it is a prime number or not.


o Display an appropriate message based on the

result.

Section D: (1 × 20 = 20 Marks)
Answer the following question.
(Each question carries 20 marks)
1. Case Study:
You are required to create a Student Management
System using Python. The system should:
o Allow the user to add, view, update, and

delete student details such as name, roll


number, and marks.
o Store the student records in a list of objects.

Your tasks are:


o Define a class Student with attributes like
name, roll_number, and marks.
o Implement methods to:
 Add a new student.

 Update a student's details.

 Delete a student's record.

 Display student details.

o Create a menu-driven program to perform


the operations.
o Use appropriate exception handling to catch
errors such as invalid inputs.
(Each question carries 2 marks)
1.What is the difference between Python 2.x
and Python 3.x?
2.What is the use of the len() function in
Python? Give an example.
3.Explain indentation in Python. Why is it
important?
4.What are lists and how are they different from
tuples?
5.How would you define a function in Python?
Provide an example.
6.What does the continue statement do in a
loop?
7.How do you import a module in Python? Give
an example.
8.What is a lambda function? Provide an
example.
9.Explain the concept of exception handling in
Python.
10. What is a class in Python? Give an
example.
11. What is the purpose of the self parameter
in a method?
12. What does the break statement do in a
loop?
Section B: (5 × 6 = 30 Marks)
Answer any five of the following questions.
(Each question carries 6 marks)
1.Write a Python program to find the factorial
of a number using a for loop.
2.Explain the different types of loops in Python.
Write a program to print numbers 1 to 10
using a while loop.
3.What are dictionaries in Python? Write a
program to store and display student
information (e.g., name, roll number, marks).
4.Write a Python program to check whether a
given number is prime or not.
5.What are list comprehensions in Python?
Write a program to find the square of all even
numbers from 1 to 20 using a list
comprehension.
6.Explain the concept of object-oriented
programming (OOP) in Python. Define a
class called Car with attributes like make,
model, and year. Add a method to display
car details.
7.Write a Python program to demonstrate
exception handling using try, except, and
finally blocks.
Section C: (3 × 10 = 30 Marks)
Answer any three of the following questions.
(Each question carries 10 marks)
1.Write a Python program to create a menu-
driven program for:
o Finding the sum of two numbers.

o Finding the difference of two numbers.

o Finding the product of two numbers.

o Finding the quotient of two numbers.

Include error handling for division by


zero.
2.Write a Python program to read a file, count
the number of lines, words, and characters in
the file, and display the count. Handle
exceptions if the file does not exist.
3.Explain how inheritance works in Python.
Write a Python program to demonstrate
inheritance by defining two classes: Person
and Employee (Employee should inherit from
Person and add an extra attribute salary).
4.Write a Python program that accepts a string
from the user and:
o Counts the number of vowels in the string.

o Reverses the string.

o Converts the string to uppercase.


5.What are modules in Python? Write a program
to create a module called
math_operations.py with functions for
addition, subtraction, and multiplication.
Import the module in another Python file and
use the functions.

Section D: (1 × 20 = 20 Marks)
Answer the following question.
(Each question carries 20 marks)
1.Case Study:
Create a student management system using
Python. The system should:
o Allow the user to add student details

(name, roll number, marks).


o Display all student details.

o Update student marks for a specific

student.
o Delete a student’s record.

Your tasks are:


o Define a class Student with attributes
like name, roll_number, and marks.
o Implement methods to add, update,
delete, and display student records.
o Use a list of objects to store the student
records.
o Implement a menu-driven program that
allows the user to perform the above
operations.

You might also like