You are on page 1of 5

Practical No.

12

GUIDELINES FOR WRITING THE PRACTICAL WRITEUP

1. Use ruled file pages for write-up of practical contents.


2. You can use both side ruled pages for the same.
3. Start each practical (experiment) write-up on new page.
4. Maintain all these practical work in a file as it will be considered for
TW (continuous assessment) of the course PWP.
5. Write question answers given and take print out of only programs or
can write it on assignment pages.
6. Complete the practical write-up in time. Don’t keep it pending.

Practical No. 12 : Write Python program to demonstrate use of Built-in Module


and User Defined Module.

1. What is a module?

Ans:
A python module can be defined as a python program file which contains a
python code including python function, class or variables.

A module in programming allows us to logically organize the python code.


A module is a single source code file. The module in python have the .py
extension. The name of the module will be the name of the file.
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.

User Defined Module- clgname.py

def clgname(str):
print("Name of College is ",str)

Main program

from clgname import *


str=input("Enter college name: ")
clgname(str)

Output:
>>> %Run exp12_1.py

Enter college name: BSIET


Name of College is BSIET
Practical No. 12

2. Write a python program that will calculate area and


circumference of circle using inbuilt Math module.
import math

def arcircle(r):

print("Area of Circle :",round((math.pi*r*r),2))

def circircle(r):

print("Circumference of Circle :",round((2*math.pi*r),2))

r=float(input("enter radius of the circle: "))

arcircle(r)

circircle(r)

Output:
>>> %Run exp12_2.py

enter radius of the circle: 5


Area of Circle : 78.54
Circumference of Circle : 31.42
Practical No. 12

3. Write a python program that will display calendar of


given month using calendar module.
import calendar

m=int(input("Enter Month: "))

y=int(input("Enter Year: "))

print(calendar.month(y,m))

Output:
>>> %Run exp12_3.py

Enter Month: 6

Enter Year: 2021

June 2021

Mo Tu We Th Fr Sa Su

1 2 3 4 5 6

7 8 9 10 11 12 13

14 15 16 17 18 19 20

21 22 23 24 25 26 27

28 29 30
Practical No. 12

4. Write a python program that will display calendar of


given year using calendar module.
import calendar

y=int(input("Enter Year: "))

# Syntax

#calendar(year, w=2, l=1, c=6, m=3)

#year Year for the calendar

#w The width between two columns. Default value is 2

#l Blank line between two rows. Default value is 1.

#c Space between two months (Column wise). Default value is 6.

#m Number of months in a row. Default value is 3.

print(calendar.calendar(y,2,1,6,4))

Output:

You might also like