QB Python 2024-25
QB Python 2024-25
27. Write a function to find the binomial coefficient of nCr, where n and r are user inputs.
28. Write functions to find the area and perimeter of a rectangle.
29. Write a program to find the area and perimeter of a circle using functions.
30. Write a function to find the maximum of three numbers.
31. Explain error handling with try-except blocks using suitable examples.
32. Write a program to illustrate the handling of TypeError and SyntaxError using try-except
blocks.
16. Differentiate between a dictionary, list and tuple with appropriate examples.
Dr. Harshavardhan B., Asst. Prof., Mech. Engg. Dept., NIE , Mysuru 3
Question Bank Introduction to Python Programming (BPLCK105B) AY 2024-25
14. Write a program that reads the contents of a text file named „data.txt‟ and prints the first
line to the console if the line ends with characters „nie‟. Use proper file handling
techniques and include comments in your code.
15. Explain the following with its syntax:
a. Get to know the current working directory
b. Creates a new directory at the specified path
c. Change the current working directory
d. Remove a directory
e. List all the files and sub directories present inside the current working directory
f. Renaming a file or directory
16. Describe the following methods of os module: i) chdir() ii) rmdir() iii) walk() iv) mkdir()
v) getcwd()
17. Write a program to create a file using shelve module and append the variables to it and
read it.
5. Write a Rectangle class and create two Rectangle objects. Write python program to check
whether the area of the first Rectangle object is greater than second Rectangle object.
(with or without operator over loading).
6. Write a class circle and create methods area() and perimeter() to find the area and
perimeter of a circle for given input radius by user.
7. Develop a program that uses class Student which prompts the user to enter marks in three
subjects and calculates total marks, percentage and displays the score card details. Use list
to store the marks in three subjects and total marks. Use __init__() method to initialize
name, USN and the lists to store marks and total. Use getMarks() method to read marks
into the list, and display() method to display the score card details. (Lab program)
---***---
Dr. Harshavardhan B., Asst. Prof., Mech. Engg. Dept., NIE , Mysuru 5