Python Unit-4 Previous Questions
On this page
- SEMESTER END EXAMINATIONS – JUNE 2024
- BACKLOG SUBJECT EXAMINATIONS – SEPTEMBER / OCTOBER 2023
- SEMESTER END EXAMINATIONS – MAY / JUNE 2023
- SUPPLEMENTARY SEMESTER EXAMINATIONS – SEPTEMBER 2022
- SUPPLEMENTARY SEMESTER EXAMINATIONS - NOVEMBER 2022
- SEMESTER END EXAMINATIONS – JUNE 2022
- EXAMINATIONS SEPTEMBER /OCTOBER 2021 SUPPLEMENTARY
- EXAMINATIONS SEPTEMBER /OCTOBER 2021 SUPPLEMENTARY
- EXAMINATIONS SEPTEMBER /OCTOBER 2020 SUPPLEMENTARY
- SEMESTER END EXAMINATIONS – JUNE 2019
- SUPPLEMENTARY SEMESTER EXAMINATIONS – JULY 2019
- MAKEUP EXAMINATIONS – JULY 2019
- SEMESTER END EXAMINATIONS – MAY/JUNE 2018
- SUPPLEMENTARY SEMESTER EXAMINATIONS – JULY/AUGUST 2018
- SEMESTER END EXAMINATIONS – MAY/JUNE 2017
- SUPPLEMENTARY SEMESTER EXAMINATIONS – AUGUST 2017
SEMESTER END EXAMINATIONS – JUNE 2024
Write a program to demonstrate multiple inheritance concept in python.
Differentiate Constructor and Destructor in python using suitable python script.
Write short note on: i) Data hiding ii) Static Member.
Write a program to demonstrate multilevel inheritance concept in python.
Differentiate class variable and instance variable in python using suitable python script.
Write short note on : i) getattr
ii) setattr
.
BACKLOG SUBJECT EXAMINATIONS – SEPTEMBER / OCTOBER 2023
Demonstrate Multiple Inheritance with Method Overriding.
Define a class Time
which has 3 members, hours, minutes and seconds. Use constructor to initialize the values and develop functions to add two times and display.
Write a Python program to check the following using regular expressions: i) A given USN of RIT MCA student is valid or not. ii) to find the sequences of one upper case letter followed by lower case letters. iii) matches a string that has an ‘a’ followed by anything, ending in ‘b’.
Demonstrate the usage of getattr()
and hasattr()
methods with a suitable example.
Define a class BankAccount
. The constructor for this class will take one argument i.e. default balance for opening an account.
Add methods to read, withdraw, deposit and display to do respective operations.
i) In the read method store account holder information like name, email, phone and type of account.
ii) If the account type is SB – add 5% interest and if account type is FD – add 8% interest to the balance.
iii) In the withdraw method check for sufficient balance before withdrawal.
List any 6 regular expression patterns in python and write the meaning of each.
SEMESTER END EXAMINATIONS – MAY / JUNE 2023
List any 5 regular expression patterns in python and write the meaning of each.
Explain constructors and destructors in python with examples.
Illustrate multilevel inheritance in Python. Also demonstrate how to pass data to the base class constructor.
Use the datetime
module to write a python program that gets the current date and prints the day of the week.
Demonstrate match()
and search()
methods w.r.t regular expressions in python.
Demonstrate the scope of class attributes and data attributes with an example.
SUPPLEMENTARY SEMESTER EXAMINATIONS – SEPTEMBER 2022
Create a class Rectangle. The constructor for this class should take two numeric arguments, which are the width and height. Add methods to compute the area and perimeter of the rectangle, as well as methods that simply return the height and width. Add a method is Square that returns a Boolean value if the rectangle is a square.
Develop script to validate the following using regular expressions, i. Email ID ii. IP address iii. Mobile number.
Define the following w.r.t classes in python. Demonstrate each of the following. (i) Constructor (ii) Destructor (iii) getattr (iv) hasattr.
Develop a script using regular expressions to search and replace a string in a given input.
SUPPLEMENTARY SEMESTER EXAMINATIONS - NOVEMBER 2022
Develop regular expressions to match the following patterns: Email Address, Mobile number, USN.
Explain the following concepts in python with example: i) Data hiding ii) Inheritance.
Explain the basic structure of class in python. Also explain the difference between data attributes and class attributes with example.
List any four regular expression patterns in python along with their meaning and example.
Define a class BankAccount. The constructor for this class will take one argument i.e. default balance for opening an account. Add methods withdraw, deposit and displayBalance to do respective operations. In the withdraw method check for sufficient balance before withdrawal.
Demonstrate the following concepts w.r.t python: i) Constructor ii) Destructor iii) self iv) del
SEMESTER END EXAMINATIONS – JUNE 2022
List any five regular expression patterns in python and write the meaning of each.
Explain the basic syntax of class in Python. Show an example defining a class which demonstrates attributes, methods, constructor and destructor.
Demonstrate Multiple Inheritance with Method Overriding.
Demonstrate self and del keyword usage in python giving a suitable example.
Demonstrate match() and search() methods w.r.t regular expressions in python.
Demonstrate the usage of getattr() and hasattr() methods with a suitable example.
Develop a python program that will illustrate the fact that class variables are shared among all instances of a class.
Design a Python class called account and implement the functions deposit, withdraw and display balance.
Demonstrate how the concept of data hiding is implemented in python.
EXAMINATIONS SEPTEMBER /OCTOBER 2021 SUPPLEMENTARY
Define the following w.r.t classes in python. Demonstrate each of the following. (i) Constructor (ii) Destructor (iii) getattr (iv) hasattr
Develop a script using regular expressions to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
Develop script using regular expressions to match a string that contains only upper and lowercase letters, numbers, and underscores.
Create a class Rectangle. The constructor for this class should take two numeric arguments, which are the width and height. Add methods to compute the area and perimeter of the rectangle, as well as methods that simply return the height and width. Add a method is Square that returns a Boolean value if the rectangle is a square.
List and explain 5 built-in classes in python and their use, with suitable example. Develop a program to demonstrate the same.
EXAMINATIONS SEPTEMBER /OCTOBER 2021 SUPPLEMENTARY
List any 6 regular expression patterns in python and write the meaning of each.
How the class created in python? Explain the basic structure of a class with example.
Illustrate multilevel inheritance in Python. Also demonstrate how to pass data to the base class constructor.
Demonstrate match() and search() methods w.r.t regular expressions in python.
Create a class Stack. Add methods to perform different stack operations like push, pop, is_empty, is_full and display.
Demonstrate Multiple Inheritance with Method Overriding.
EXAMINATIONS SEPTEMBER /OCTOBER 2020 SUPPLEMENTARY
Explain the basic syntax of class in Python. Show an example defining a class which demonstrates attributes, methods, constructor and destructor.
Write the general syntax of getattr() and hasattr() methods. Also show the usage with an example.
How do you define and use regular expressions in Python? Discuss.
Demonstrate the following concepts in python: i) Data Hiding ii) Inheritance iii) Static Members iv) del keyword.
Write a Python program to check the validity of a password given by the user using regular expression. The Password should satisfy the following criteria: i. Contain at least 1 letter between a and z ii. Contain at least 1 number between 0 and 9 iii. Contain at least 1 letter between A and Z iv. Contain at least 1 character from $, #, @ v. Minimum length of password: 6 vi. Maximum length of password: 12.
SEMESTER END EXAMINATIONS – JUNE 2019
Define the following w.r.t classes in python. Demonstrate each of the following. (i) Constructor (ii) Destructor (iii) getattr (iv) hasattr.
How do you define regular expressions in python? Write regular expression to match the following patterns: (i) The file names chap01, chap02, chap03, chap10, chap11 and chap12 (ii) containing ‘RIT’ as an embedded string except at the beginning or end (iii) the file names that end with at least two digits and don’t begin with an alphabet (iv) the files except ‘.py’ extension
Create a class called Stack, Add methods to perform different stack operations like push, pop, is_empty,is_full and display.
Explain data attributes and class attributes? Develop a python program that will illustrate the fact that class variables are shared among all instances of a class.
SUPPLEMENTARY SEMESTER EXAMINATIONS – JULY 2019
Explain the following concepts in detail: i.Data hiding ii.Inheritance iii.Static members.
Define the following w.r.t classes in python. Show the code snippets to define/show the usage of each. (i) Constructor (ii) Destructor (iii) getattr (iv) hasattr.
What are data attributes and class attributes? Create a python program that will illustrate the fact that class variables are shared among all instances of a class.
List any 6 regular expression patterns in python and write the meaning of each.
MAKEUP EXAMINATIONS – JULY 2019
What is the difference between a method and a function? Give an example each.
Design a Python class called account and implement the functions deposit, withdraw and display balance.
Explain different ways of accessing attributes in a class.
Describe the following along with example wrt to python: i) Constructor ii) destructor iii) self keyword iv) del keyword v) static members.
Explain the inheritance in python.
List any 6 regular expression patterns in python along with their meaning and example.
SEMESTER END EXAMINATIONS – MAY/JUNE 2018
Suppose you are designing the software for an ATM (Automatic Teller Machine). Write at least three different scenarios describing the use of your system. From these create CRC cards to describe the various classes that might be used to implement your design. Walk through your scenarios to make sure that all activity is matched to a class.
What are data attributes and class attributes? Create a python program that will illustrate the fact that class variables are shared among all instances of a class.
Create a class Rectangle. The constructor for this class should take two numeric arguments, which are the width and height. Add methods to compute the area and perimeter of the rectangle, as well as methods to that return the height and width. Add a method is Square that returns a Boolean value if the rectangle is a square.
List any 6 regular expression patterns in python and write the meaning of each.
SUPPLEMENTARY SEMESTER EXAMINATIONS – JULY/AUGUST 2018
Define the following w.r.t classes in python. Show the code snippets to define/show the usage of each. (i) Constructor (ii) Destructor (iii) getattr (iv) hasattr.
Explain the following concepts in detail: i. Data hiding ii. Inheritance iii. Static members.
Create a class Rectangle. The constructor for this class should take two numeric arguments, which are the width and height. Add methods to compute the area and perimeter of the rectangle, as well as methods that simply return the height and width. Add a method is Square that returns a Boolean value if the rectangle is a square.
How do you define regular expressions in python? Write regular expression to match the following patterns: (i) The file names chapa, chapb, chapc, chapx, chapy and chapz. (ii) containing ‘msrit’ as an embedded string except at the beginning or end . (iii) the file names that end with at least two digits and don’t begin with an alphabet. (iv) the files except ‘.py’ extension
SEMESTER END EXAMINATIONS – MAY/JUNE 2017
Write a regular expression to validate a float number it should satisfy the following. i. Number can start with +, - or . symbol. ii. Number must contain at least 1 decimal value. iii. Number must have exactly one . symbol.
Explain the following concepts in detail, i. Data hiding ii. Inheritance iii. Static members
Define a class BankAccount. The constructor for this class will take one argument i.e. default balance for opening an account. Add methods withdraw, deposit and displayBalance to do respective operations. In the withdraw method check for sufficient balance before withdrawal. And also keep track of number of bank accounts.
Develop a script using regular expressions to search and replace a string in a given input.
SUPPLEMENTARY SEMESTER EXAMINATIONS – AUGUST 2017
Suppose you are designing the software for an ATM (Automatic Teller Machine). Write at least three different scenarios describing the use of your system. From these create CRC cards to describe the various classes that might be used to implement your design. Walk through your scenarios to make sure that all activity is matched to a class.
What are data attributes and class attributes? Create a python program that will illustrate the fact that class variables are shared among all instances of a class.
Create a class Rectangle. The constructor for this class should take two numeric arguments, which are the width and height. Add methods to compute the area and perimeter of the rectangle, as well as methods to that return the height and width. Add a method isSquare that returns a Boolean value if the rectangle is a square.
List any 6 regular expression patterns in python and write the meaning of each.