Computer Workshop (Python Programming) (CY-306) - Important Questions
-
Unit 414 Marks High Priority
Design a Python class BankAccount with attributes account_number and balance. Implement methods deposit(amount), withdraw(amount) and display_balance(). Ensure withdrawal checks for insufficient funds. Create two account objects, perform a sequence of deposits and withdrawals on each, and show the output after each operation.
Core practical/class design question; frequently asked in past papers on classes and objects.
-
Unit 47 Marks Medium Priority
Explain the difference between a class and an object in Python. Provide a short code example that declares a simple class and creates two different objects demonstrating distinct instance attribute values.
Fundamental conceptual question about basic OOP terminology; commonly asked in short-answer form.
-
Unit 47 Marks Medium Priority
Write a Python class Student that demonstrates the difference between class variables and instance variables. Also add a @staticmethod and a @classmethod to illustrate their use. Provide sample output showing the difference when multiple objects are created.
Covers class vs instance vs static members and use of decorators; appears occasionally.
-
Unit 47 Marks Medium Priority
Explain encapsulation in Python. Write a class Employee with a private attribute salary and provide getter and setter methods (or use property) to access and modify salary safely. Demonstrate with an example.
Practical coding: encapsulation and access control—typical short question on classes.
-
Unit 414 Marks High Priority
Explain different types of inheritance in Python (single, multilevel, multiple, hierarchical). Write Python programs to demonstrate multilevel inheritance and multiple inheritance. Comment on advantages and common pitfalls.
Core inheritance topic covering types and implementation; high priority within Unit 4.
-
Unit 47 Marks Medium Priority
Write classes Parent and Child where Child inherits from Parent. Demonstrate method overriding in Child and use super() to call the parent's constructor and a parent method from the child class. Show sample output.
Method overriding and constructor chaining using super(); commonly asked practical task.
-
Unit 47 Marks Medium Priority
What is Method Resolution Order (MRO) in Python? Illustrate MRO with an example that creates a diamond inheritance pattern and explain how Python determines which method implementation to call.
Covers Method Resolution Order (MRO) and diamond problem—standard conceptual/coding question in inheritance.
-
Unit 47 Marks High Priority
Explain the try-except-else-finally construct in Python with an example that catches multiple exception types. Show how the else and finally blocks execute depending on whether an exception occurs.
Core exception handling construct question; frequent in past papers for Unit 4.
-
Unit 47 Marks Low Priority
Define a custom exception class InvalidAgeError and write code that raises this exception when an invalid age is provided to a function set_age(age). Demonstrate catching this specific exception and handling it.
Practical question about raising and handling user-defined exceptions; useful for error management topics.
-
Unit 47 Marks Low Priority
Write a Python program to read lines from a file specified by the user, count words per line and total words. Handle exceptions such as FileNotFoundError and permission errors gracefully using try-except, and ensure the file is properly closed (use with statement or finally).
Combines file I/O with exception handling; common applied question though less frequent than core try-except questions.
Quick Add to Notes
Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.
Create free accountHave an account? Log in
Notes Panel