Practical No : 12
Name: Shivraj Prakash Chougule Roll No.12
Practical Name : Write Python program to demonstrate use of:
a) Built-in module (e.g. keyword, math, number, operator)
b) User defined module
Q.1) What is the output of the following program?
Code :
import math
print math.sqrt(25)
print math.pi
print math.degrees(2)
print math.radians(60)
print math.sin(2)
print math.cos(0.5)
print math.tan(0.23)
print math.factorial(4)
Output :
Q.2) What is the output of the following program?
Code :
import random
print(random.randint(0, 5))
print(random.random())
print(random.random() * 100)
List = [1, 4, True, 800, "Python", 27, "hello"]
print(random.choice(List))
Output :
Q3) What is the output of the following program?
Code :
import datetime
from datetime import date
import time
print(time.time())
print(date.fromtimestamp(454554))
Output :
Exercise:
Q.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 :
main.py :
import college
college_name = college.college_name()
print("Your college name is:", college_name)
College.py:
def college_name():
college_name = input("Enter your college name: ")
return college_name
Output :
Q.2)Write a Python program that will calculate area and circumference of circle using inbuilt Math Module
Code :
import math
radius = float(input("Enter the radius of the circle: "))
area = math.pi * radius ** 2
circumference = 2 * math.pi * radius
print("Area:", area)
print("Circumference:", circumference)
Output :
Q.3) Write a Python program that will display Calendar of given month using Calendar Module
Code :
import calendar
year = int(input("Enter the year (e.g. 2025): "))
month = int(input("Enter the month (1-12): "))
print(calendar.month(year, month))
Output :