PRACTICAL FILE
Python Lab
(BCA-406)
Session 2024-2025
Submitted To Submitted By
Dr. Archana Sandhu Nikhil Kumar
Associate professor Roll No – 1322182
MMICT & BM BCA- “C” Group 1
Branch- MMICT&BM
M.M. INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT
MAHARISHI MARKANDESHWAR (DEEMED TO BE UNIVERSITY)
MULLANA–AMBALA, HARYANA (INDIA) – 133207
(Established under Section 3 of the UGC Act, 1956
(Accredited by NAAC with Grade A++)
Z1
Sr. Experiment
No. Experiment Description Date Page No. Remark
No.
Installation of python and Pycharm (IDE for
Python) and test a basic python program in
1. BCA-406-1
both Script and Interactive mode
To write a python program that takes in
2. BCA-406-2 command line arguments as input and print the
number of arguments.
3. Write a python program to illustrate the
BCA-406-3 various functions of math module
Write a menu driven program in python to
4. calculate the area of different shapes using a
BCA-406-4
while loop
Write a program in python to create a
Dictionary and apply all the operation
5. BCA-406-5
applicable for the list.
Write a program in python for reading and
6. BCA-406-6
writing data on a external file
Write a program in python to create a class and
apply following concepts of Object Oriented
7. BCA-406-7
Programming i) Inheritance ii) Function
Overloading iii) Operator Overloading
Develop a Calculator (GUI Interface) using
8. BCA-406-8
Tkinter in Python.
Write a program in python for connecting to a
9. BCA-406-9 Database. Perform insertion, deletion and
updation operation in the database
Develop a Restaurant Management (GUI
10. BCA-406-10
Interface) using Tkinter in Python
Z2
MM INSTITUTE OF COMPUTER TECHNOLOGY & LABORATORY MANUAL
BUSINESS MANAGEMENT-MULLANA
MMICT&BM PRACTICAL EXPERIMENT INSTRUCTION SHEET
Title: Installation of python and Pycharm (IDE for Python) and test a basic python program in
both Script and Interactive mode
EXPERIMENT NO.: BCA-406 ISSUE No. : 01 ISSUE DATE:
REV. DATE: REV. No.: 00 Dept. MCA
LABORATORY: Python Lab Semester-4th Page: 2 to 3
Step 1: Download Python
Visit the Python Official Website:
Go to the Python Downloads page.
Choose Youí Veísion:
Select the veísion of Python you want to download. Foí beginneís, Python 3.x is íecommended.
Download the Installeí:
Click on the download link foí youí opeíating system (Windows, macOS, oí Linux). ľhe installeí
file will have a .exe extension foí Windows, .pkg foí macOS, oí .tar.gz foí Linux.
Step 2: Install Python
Run the Installeí:
Locate the downloaded installeí file and double-click it. Ir Qo"’íc o⭲ Wi⭲dows, íigkt-click a⭲d
ckoosc “R"⭲ as admi⭲istíatoí.”
Add Python to PAľH:
K"íi⭲g i⭲stallatio⭲, ckcck tkc box tkat saQs “Add PQtko⭲ «.x to PAľH.” ľkis c⭲s"ícs tkat Qo" ca⭲ í"⭲
PQtko⭲
fíom the command line without specifying its full path.
Z3
Stcp «: VcíifQ I⭲stallatio⭲
Open Command Píompt (Windows) oí ľeíminal (macOS/Linux): ľQpc python --version a⭲d pícss E⭲tcí.
You skould scc tkc i⭲stallcd PQtko⭲ :císio⭲
tkc i⭲stallcd PQtko⭲ :císio⭲
Download PyChaím:
Go to tkc PyCharm Downloads page.
Yo"’ll scc two optio⭲s: Píofessional a⭲d Community
ľkc Community edition is rícc a⭲d opc⭲-so"ícc, wkilc tkc Píofessional
edition orrcís additio⭲al rcat"ícs (b"t ícq"iícs a licc⭲sc).
Sclcct tkc cditio⭲ tkat s"its Qo"í ⭲ccds.
Click tkc “DOWNLOAD” li⭲k coíícspo⭲di⭲g to tkc cditio⭲ Qo"’:c ckosc⭲.
ľkis will dow⭲load tkc i⭲stallcí filc.
I⭲ tkc ľoolbox App, sclcct PyChaím ríom tkc list or a:ailablc píod"cts.
Ckoosc tkc :císio⭲ Qo" wa⭲t to i⭲stall (c.g., Comm"⭲itQ oí Píorcssio⭲al).
ľkc ľoolbox App will ka⭲dlc tkc i⭲stallatio⭲ píoccss a⭲d licc⭲sc acti:atio⭲.
Z4
MM INSTITUTE OF COMPUTER TECHNOLOGY & LABORATORY MANUAL
BUSINESS MANAGEMENT-MULLANA
MMICT&BM PRACTICAL EXPERIMENT INSTRUCTION SHEET
Title: Write a python program to illustrate the various functions of math module
EXPERIMENT NO.: BCA-406 ISSUE No. : 03 ISSUE DATE:
REV. DATE: REV. No.: 00 Dept. MCA
LABORATORY: Python Lab Semester-4th Page: 06 to 07
import math
print(f"The value of pi is:
{math.pi}") num = 16
print(f"The square root of {num} is: {math.sqrt(num)}")
num = 5
print(f"The factorial of {num} is: {math.factorial(num)}")
num1, num2 = 24, 36
print(f"The greatest common divisor of {num1} and {num2} is: {math.gcd(num1,
num2)}")
base, exp = 2, 3
print(f"{base} to the power of {exp} is: {math.pow(base, exp)}")
angle = math.pi / 2
print(f"The sine of {angle} radians is: {math.sin(angle)}")
print(f"The cosine of {angle} radians is: {math.cos(angle)}")
print(f"The tangent of {angle} radians is: {math.tan(angle)}")
degrees = 180
print(f"{degrees} degrees in radians is: {math.radians(degrees)}")
radians = math.pi
print(f"{radians} radians in degrees is: {math.degrees(radians)}")
Z5
Output:
Z6
MM INSTITUTE OF COMPUTER TECHNOLOGY & LABORATORY MANUAL
BUSINESS MANAGEMENT-MULLANA
PRACTICAL EXPERIMENT INSTRUCTION SHEET
MMICT&BM
Title: Write a menu driven program in python to calculate the area of different shapes using a
while loop.
EXPERIMENT NO.: BCA-406 ISSUE No. : 04 ISSUE DATE:
REV. DATE: REV. No.: 00 Dept. MCA
LABORATORY: Python Lab Semester-4th Page: 08 to 09
import math
def calculate_circle_area(radius):
return math.pi * radius ** 2
def calculate_rectangle_area(length, width):
return length * width
def calculate_triangle_area(base,
height): return 0.5 * base * height
def main():
while True:
print("\nMenu:")
print("1. Calculate Circle Area")
print("2. Calculate Rectangle Area")
print("3. Calculate Triangle Area")
print("4. Quit")
choice = input("Enter your choice (1-4):
") if choice in ['1', '2', '3']:
if choice == '1':
radius = float(input("Enter the radius of the circle:
")) area = calculate_circle_area(radius)
print("The area of the circle is:",
area) elif choice == '2':
length = float(input("Enter the length of the
rectangle: ")) width = float(input("Enter the width of
the rectangle: ")) area =
calculate_rectangle_area(length, width)
print("The area of the rectangle is:",
area) elif choice == '3':
base = float(input("Enter the base of the triangle: "))
height = float(input("Enter the height of the triangle:
")) area = calculate_triangle_area(base, height)
print("The area of the triangle is:",
area) elif choice == '4':
print("Exiting program. Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1 and 4.")
if name == " main ":
main()
Z7
Z8
Output:
Z9
MM INSTITUTE OF COMPUTER TECHNOLOGY & LABORATORY MANUAL
BUSINESS MANAGEMENT-MULLANA
MMICT&BM PRACTICAL EXPERIMENT INSTRUCTION SHEET
Title Write a program in python to create a Dictionary and apply all the operation applicable
for the list.
EXPERIMENT NO.: BCA-406 ISSUE No. : 05 ISSUE DATE:
REV. DATE: REV. No.: 00 Dept. MCA
LABORATORY: Python Lab Semester-4th Page: 10 to 11
my_dict = {
'name': 'Atul kumar',
'age': 25,
'city': 'West champarn'
}
print("Original dictionary:", my_dict)
my_dict['email'] = '[email protected]'
print("Dictionary after adding a new item:",
my_dict)
my_dict['age'] = 26
print("Dictionary after updating age:", my_dict)
del my_dict['city']
print("Dictionary after removing city:",
my_dict) print("Accessing the name:",
my_dict['name'])
keys_list = list(my_dict.keys())
print("Keys in the dictionary:",
keys_list)
values_list = list(my_dict.values())
print("Values in the dictionary:",
values_list)
items_list = list(my_dict.items())
print("Key-value pairs in the dictionary:", items_list)
key_to_check = 'name'
if key_to_check in my_dict:
print(f"'{key_to_check}' is a key in the
dictionary.") else:
print(f"'{key_to_check}' is not a key in the dictionary.")
print("Iterating over keys:")
for key in my_dict:
print(key)
Z1
0
print("Iterating over key-value
pairs:") for key, value in
my_dict.items():
print(f"{key}: {value}")
Z1
1
Output:
Z10