Gramin Technical and Management Campus
Department of computer engineering
Subject/code: -Python/22616
Name:-Pranusha Shiddhodhan Birhade
DOP: DOS:-
Practical No 12
1) Write a Python program to create a user defined module that will
ask your college name and will display the name of the college.
Code:-
# college_module.py
def get_college_name():
college_name = input("Please enter your college name: ")
return college_name
# main.py
import college_module
def main():
college_name = college_module.get_college_name()
print(f"The name of your college is: {college_name}")
if __name__ == "__main__":
main()
Output:-
2) Write a Python program that will calculate area and circumference
of circle using inbuilt Math Module
Code:-
import math
def calculate_circle_properties(radius):
area = math.pi * (radius ** 2)
circumference = 2 * math.pi * radius
return area, circumference
if __name__ == "__main__":
try:
radius = float(input("Enter the radius of the circle: "))
if radius < 0:
print("Radius cannot be negative. Please enter a non-negative value.")
else:
area, circumference = calculate_circle_properties(radius)
print(f"Area of the circle: {area:.2f}")
print(f"Circumference of the circle: {circumference:.2f}")
except ValueError:
print("Invalid input. Please enter a numeric value for the radius.")
Output:-
3) Write a Python program that will display Calendar of given month
using Calendar Module
Code:-
import calendar
def display_calendar(year, month):
cal = calendar.TextCalendar()
month_calendar = cal.formatmonth(year, month)
print(month_calendar)
if __name__ == "__main__":
try:
year = int(input("Enter the year (e.g., 2023): "))
month = int(input("Enter the month (1-12): "))
if 1 <= month <= 12:
display_calendar(year, month)
else:
print("Invalid month. Please enter a value between 1 and 12.")
except ValueError:
print("Invalid input. Please enter numeric values for year and month.")
Output:-