IT 243 Programming With Python
IT 243 Programming With Python
Full Marks: 60
(NCCS-College of IT & Management) Pass Marks: 30
Pre-Board Examination (2024) Time: 3 Hours
Set A
BIM/Fifth Semester/ IT 243: Programming with Python
Candidates are required to answer the questions in their own words as far as practicable.
Attempt all questions.
Group ‘A’
Brief Answer Questions: [10×1=10]
1. How do you call a superclass constructor from a subclass in Python?
2. What happens if the method signature is different in the superclass and subclass during overriding?
3. How do you resolve conflicts in multiple inheritance?
4. How do you overload the greater than operator in Python?
5. How do you access the name and value of an enum member?
6. How do you handle exceptions in file handling?
7. How can we implement id() in python?
8. How do you change the text of a Tkinter Label widget dynamically?
9. How do decorators modify the behavior of a function?
10. How do you use **kwargs to pass keyword arguments to a function?
Group ‘B’
Short Answer Questions (Any Five): [5×3=15]
11. How do you use a lambda function with the map() function? Explain with examples.
12. How would you add a menu bar with "File" and "Edit" options to your Tkinter application?
13. What are the different types of inheritance in Python? Provide examples to illustrate single, multiple, and
multilevel inheritance.
14. Create a Python program to demonstrate abstraction using a base class Employee with an abstract method
calculate_salary(), and derived classes FullTimeEmployee and PartTimeEmployee that implement
calculate_salary().
15. Discuss the use of default values in constructors. Write a class Student with a constructor that initializes
name and grade with a default value of None.
16. Write a Python class Person with a method that can introduce the person with different levels of detail based
on the arguments provided.
Group ‘C’
Long Answer Questions (Any three): [3×5=15]
17. Write a python code to display:
18. Write a Python program to demonstrate the use of the finally block for resource cleanup. Use a try block to
handle file operations and ensure the file is closed using the finally block.
19. Create a Python program that iterates through a list of strings and prints each string that starts with the letter
"A".
20. Write a Python program that reads a file and counts the number of occurrences of each word in the file. The
program should then print each word alongside its count.
Group ‘D’
******
National College of Computer Studies
Full Marks: 60
(NCCS-College of IT & Management) Pass Marks: 30
Pre-Board Examination (2024) Time: 3 Hours
Set B
BIM/Fifth Semester/ IT 243: Programming with Python
Candidates are required to answer the questions in their own words as far as practicable.
Attempt all questions.
Group ‘A’
Brief Answer Questions: [10×1=10]
1. Explain the importance of indentation in python.
2. How does method overriding affect polymorphism?
3. How do you create an abstract class with no abstract methods?
4. What is the purpose of the else block in exception handling?
5. How do you read a file line by line in Python?
6. What is the purpose of the cursor object in database operations?
7. How do you handle button click events in Tkinter?
8. What happens if you call a function with more arguments than it accepts?
9. What is the default return value of a function if no return statement is specified?
10. What is the potential issue with using mutable default arguments?
Group ‘B’
Short Answer Questions (Any Five): [5×3=15]
11. How can you achieve similar behavior to function overloading using default arguments and variable
arguments? Explain with examples.
12. Write a function that is called when a button is clicked, which changes the text of a Label to "Button
Pressed."
13. Write a Python program to demonstrate hierarchical inheritance. Create a base class Animal and derived
classes Mammal and Bird.
14. What are the benefits of using abstract classes in large software projects? Provide an example to illustrate
the advantages of abstract classes in Python. Discuss the limitations of abstract classes in Python.
15. Write a Python class Product with a constructor that initializes name, price, and quantity. Include methods
to display the product details and calculate the total price.
16. Create a Python class Shape with a method area that can calculate the area of a square, rectangle, or circle
based on the number of arguments provided.
Group ‘C’
Long Answer Questions (Any three): [3×5=15]
17. Write a python code to create the following:
18. Explain the importance of exception handling in Python. How can you define and raise custom exceptions
in Python? Write a custom exception InvalidAgeError and demonstrate its use in a program that checks for
valid age input.
19. Write a Python function that takes a list of integers as input and writes each integer to a new line in a text
file. Then, write another function that reads the integers back from the file and returns them as a list.
20. Write a Python program that reverses a string using a for loop, using slicing and using reversed() function
combined with the join().
Group ‘D’
******