Program no :- 01 Date :- 10 / 12 /2025
Program Name :- Write a simple Python Function to check Whether
x is even or odd.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
def check_even_odd(x):
if x % 2 == 0:
print(x, "is Even")
else:
print(x, "is Odd")
check_even_odd(9)
check_even_odd(18)
Output:
9 is Odd
18 is Even
Program no :- 02 Date :-12/12/2025
Program Name :- Write a simple python program to demonstrate
default arguments to function.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
def greet(name, message="welcome"):
print(message, name)
greet("Hash")
greet("Hash", "Good Morning")
Output:
welcome Hash
Good Morning Hash
Program no :- 03 Date :- 17/12/2025
Program Name :- Write a simple module ([Link]) for addition or
subtraction.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
def add(a, b):
return a + b
def subtract(a, b):
return a - b
x = 30
y = 18
print("Addition:", add(x, y))
print("Subtraction:", subtract(x, y))
Output:
Addition: 48
Subtraction: 12
Program no :- 04 Date :- 24/12/2025
Program Name :- Write a program for importing sqrt() and factorial
from the module path.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
from math import sqrt, factorial
a = 60
b=7
print("Square root of", a, "is", sqrt(a))
print("Factorial of", b, "is", factorial(b))
Output:
Square root of 60 is 7.745966692414834
Factorial of 7 is 5040
Program no :- 05 Date :-07/01/2026
Program Name :- Write a Python program to handle simple runtime
error.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
try:
num1 = int(input("Enter numerator: "))
num2 = int(input("Enter denominator: "))
result = num1 / num2
print("Result:", result)
except ZeroDivisionError:
print("Error: Cannot divide by zero!")
except ValueError:
print("Error: Invalid input! Please enter integers.")
Output:
Enter numerator: 10
Enter denominator: 2
Result: 5.0
Enter numerator: 2
Enter denominator: h
Error: Invalid input! Please enter integers.
Program no :- 06 Date :- 14/01/2026
Program Name :- Write a program to handle multiple errors with
one except statement.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
try:
num1 = int(input("Enter numerator: "))
num2 = int(input("Enter denominator: "))
result = num1 / num2
print("Result:", result)
except (ZeroDivisionError, ValueError) as e:
print("Error occurred:", e)
Output:
Enter numerator: 3
Enter denominator: 23
Result: 0.13043478260869565
Enter numerator: 3
Enter denominator: h
Error occurred: invalid literal for int() with base 10: 'h'
Program no :- 07 Date :-16/01/2026
Program Name :- Write a python program to create user-defined
exception.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
class NegativeNumberError(Exception):
def __init__(self, message="Negative numbers are not allowed!"):
[Link] = message
super().__init__([Link])
def check_positive(number):
if number < 0:
raise NegativeNumberError()
else:
print("You entered:", number)
try:
num = int(input("Enter a number: "))
check_positive(num)
except NegativeNumberError as e:
print("Error:", e)
Output:
Enter a number: 23
You entered: 23
Program no :- 08 Date :- 21/01/2026
Program Name :- Write python code to illustrate clean up (finally)
actions.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
try:
num1 = int(input("Enter numerator: "))
num2 = int(input("Enter denominator: "))
result = num1 / num2
print("Result:", result)
except ZeroDivisionError:
print("Error: Cannot divide by zero!")
finally:
print("This block always executes (cleanup actions).")
Output:
Enter numerator: 70
Enter denominator: 90
Result: 0.7777777777777778
Program no :- 09 Date :- 04/02/2026
Program Name :- Write a program to demonstrate the use of c
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
class Person:
def __init__(self, name, age):
[Link] = name
[Link] = age
def display(self):
print("Name:", [Link])
print("Age:", [Link])
person1 = Person("Hash", 21)
person2 = Person("Mangesh", 22)
[Link]()
[Link]()
Output:
Name: Hash
Age: 21
Name: Mangesh
Age: 22
Program no :- 10 Date :- 18/02/2026
Program Name :- Write a Python program to demonstrate
inheritance.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
class Person:
def __init__(self, name, age):
[Link] = name
[Link] = age
def display(self):
print("Name:", [Link])
print("Age:", [Link])
class Student(Person):
def __init__(self, name, age, student_id):
super().__init__(name, age)
self.student_id = student_id
def show_student_id(self):
print("Student ID:", self.student_id)
s1 = Student("Hash", 21, "777")
[Link]()
s1.show_student_id()
Output : Name: Hash
Age: 21
Student ID: 777
Program no :- 11 Date :- 25/02/2026
Program Name Write a python program to demonstrate
overloading.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
class Calculator:
def add(self, a, b, c=0):
return a + b + c
calc = Calculator()
print("Addition of 2 numbers:", [Link](10, 20))
print("Addition of 3 numbers:", [Link](10, 20, 30))
Output :
Addition of 2 numbers: 30
Addition of 3 numbers: 60
Program no :- 12 Date :- 04/03/2026
Program Name :-Write a python program to demonstrate overriding.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
class Calculator:
def add(self, *args):
total = sum(args)
return total
calc = Calculator()
print("Addition of 2 numbers:", [Link](10, 20))
print("Addition of 3 numbers:", [Link](10, 20, 30))
print("Addition of 5 numbers:", [Link](1, 2, 3, 4, 5))
Output :
Addition of 2 numbers: 30
Addition of 3 numbers: 60
Addition of 5 numbers: 15
Program no :- 13 Date :- / /
Program Name :- Write a Python Program for Insertion Sort.
Teacher Name:- Dr. Rajendra Budake Sign :-
Student Name :- Harshad Vilas Maskar
Ans.
Input:
Output :