0% found this document useful (0 votes)
5 views4 pages

Python Pra12

The document contains practical exercises for a Python course, including creating a user-defined module to display a college name, calculating the area and circumference of a circle using the math module, and displaying a calendar for a given month using the calendar module. Each exercise includes sample code and error handling for user input. The practical aims to enhance programming skills in Python through hands-on coding tasks.

Uploaded by

birhadepranusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Python Pra12

The document contains practical exercises for a Python course, including creating a user-defined module to display a college name, calculating the area and circumference of a circle using the math module, and displaying a calendar for a given month using the calendar module. Each exercise includes sample code and error handling for user input. The practical aims to enhance programming skills in Python through hands-on coding tasks.

Uploaded by

birhadepranusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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:-

You might also like