0% found this document useful (0 votes)
3 views4 pages

Test Python 2

The document outlines a question paper for advanced Python coding, focusing on Object-Oriented Programming (OOP) and functions, with a total of 10 questions worth 50 marks. Each question requires writing Python programs to demonstrate concepts such as constructors, method overriding, encapsulation, inheritance, multiple inheritance, recursion, lambda functions, variable arguments, abstract classes, and higher-order functions. Each question is worth 5 marks and emphasizes practical coding skills.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Test Python 2

The document outlines a question paper for advanced Python coding, focusing on Object-Oriented Programming (OOP) and functions, with a total of 10 questions worth 50 marks. Each question requires writing Python programs to demonstrate concepts such as constructors, method overriding, encapsulation, inheritance, multiple inheritance, recursion, lambda functions, variable arguments, abstract classes, and higher-order functions. Each question is worth 5 marks and emphasizes practical coding skills.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced Python Coding Questions

Topic: OOPs & Functions

Total Marks: 50

Instructions:

Attempt all questions.


Each question carries 5 marks.
Write proper Python programs with output.

Question 1: Constructor & Instance Variables


Create a class Student with:

instance variables: name , roll_no , and marks


a constructor to initialize values
a method display() to print student details.

Create objects for two students and display their details.

Marks: 5

Question 2: Method Overriding


Create a base class Animal with a method sound() .

Create derived classes Dog and Cat that override the sound() method.

Demonstrate runtime polymorphism using object references.

Marks: 5
Question 3: Encapsulation
Create a class BankAccount with:

private variable balance


methods deposit() , withdraw() , and check_balance()

Ensure users cannot access the balance directly.

Marks: 5

Question 4: Inheritance with Employee


System
Create a class Employee containing:

employee name
salary

Create a derived class Manager with an additional variable department .

Display complete manager details using inheritance.

Marks: 5

Question 5: Multiple Inheritance


Create two classes:

Father with method skills()


Mother with method talent()

Create a child class Child inheriting both classes and display all methods.

Marks: 5
Question 6: Recursive Function
Write a recursive function to find the factorial of a number.

Example:
Input: 5
Output: 120

Marks: 5

Question 7: Lambda Function & Sorting


Write a Python program to:

create a list of tuples containing student names and marks


sort the list using a lambda function based on marks.

Example:

[("Amit", 78), ("Rahul", 90), ("Priya", 85)]

Marks: 5

Question 8: Function with *args and **kwargs


Write a function that:

accepts multiple numbers using *args


accepts student details using **kwargs
prints the sum of numbers and all keyword details.

Marks: 5

Question 9: Abstract Class


Using the abc module:

create an abstract class Shape


create abstract method area()
implement subclasses Rectangle and Circle .

Calculate and display areas.

Marks: 5

Question 10: Higher Order Function


Write a Python program using:

map() to square all numbers in a list


filter() to display only even numbers.

Example:

numbers = [1,2,3,4,5,6]

Marks: 5

End of Question Paper

You might also like