Python File01
Python File01
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
Z1
Sr. Experiment
No. Experiment Description Date Page No. Remark
No.
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
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⭲
Download PyChaím:
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
import math
{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)}")
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)}")
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.
import math
def calculate_circle_area(radius):
return math.pi * radius ** 2
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")
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'
}
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['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