0% found this document useful (0 votes)
5 views

pythonmanual

The document is a lab manual for a Python Programming course, detailing experiments and objectives for students in the Computer and Civil Engineering departments for the academic year 2024-25. It includes a list of experiments, their aims, codes, and expected outcomes, focusing on various Python programming concepts such as data types, control flow, functions, file handling, and GUI development. Additionally, it outlines the assessment criteria for term work and practical exams.

Uploaded by

mayureshteli772
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 views

pythonmanual

The document is a lab manual for a Python Programming course, detailing experiments and objectives for students in the Computer and Civil Engineering departments for the academic year 2024-25. It includes a list of experiments, their aims, codes, and expected outcomes, focusing on various Python programming concepts such as data types, control flow, functions, file handling, and GUI development. Additionally, it outlines the assessment criteria for term work and practical exams.

Uploaded by

mayureshteli772
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/ 21

LAB MANUAL

PYTHON PROGRAMMING
LAB
(CODE: VSEC202)

Name:
Class: FE Computer Engineering & Civil & Planning
Semester:II
Roll No:
Batch:

BY

DEPARTMENT OF COMPUTER & C I V I L

ENGINEERING

Academic Year: 2024-25


31
Certificate

This is to certify that Mr. Ms._______________________________________


of Semester II Branch Computer Engineering /Civil Engineering Roll No.____has
performed and successfully completed the entire practical’s in the subject of Python
Programming Lab for the academic year 2024 -2025 as prescribed by University
of Mumbai.

Date :-

Subject Teacher Internal Examiner

Head of Department External Examiner

DEPARTMENT OF COMPUTER & CIVIL ENGINEERING

COLLEGE SEAL

32
INDEX
Ex
p. Experiment Name Lab Date of Date of Marks Sign.
Performance Completion
No. Objective
1 Personalized Greeting Generator
Calculating Area of circle
LO1
Calculating Gross Salary of an
employee
Calculating Simple Interest
Exploring Basic Arithmetic Operations
in Python
Task List Manager LO1
2
Student Enrollment Manager LO1
3
Student Record Keeper LO1
4

5 Number Type Identifier LO2


Factorial Generator
6 LO2
Prime Number Analyzer
7 LO2
Simple Calculator Using Functions
8 LO2
Extracting Words from Text File
9 LO3
Building an Executable File
10 LO3
Basic Exception Handling
11 LO3
Using a Debugger
12 LO3
13 Event Management System
LO4

33
14 GUI for Developing coversion utilities LO5

15 Script to Validate Phone Number and LO5


Email ID
16 Extracting Data from Text LO5

17 Creating and Manipulating Arrays LO6


Array Mathematics
18 Statistical Operations LO6

TOTAL MARKS

34
DEPARTMENT OF COMPUTER ENGINEERING

Lab Objectives:

1. To familiarize learners with Python's basic syntax, variables, data types, operators, and
input/output functions.
2. To reinforce the understanding and application of conditional statements, loops, and
functions in Python programming.
3. To instill learners on file handling, exception management, and Python packaging.
4. To Introduce object-oriented programming principles and their application in Python.
5. To explore advanced topics such as regular expressions, pattern matching, and GUI
development.
6. To introduce and demonstrate the use of popular Python libraries for data handling

Lab Outcome:-

Lab Outcomes: Learner will be able to

1. Demonstrate the proficiency in basic python programming or Create and perform various
operations on data structures like list, tuple dictionaries and strings.
2. Apply Control Flow and Functions for efficient coding to solve problems.
3. Demonstrate proficiency in handling file operations, managing exceptions, and
developing Python packages and executable files for modular programming.
4. Illustrate the concept of Object-Oriented Programming used in python.
5. Design Graphical User Interface (GUI) applications, utilizing appropriate Python
libraries to create user-friendly interfaces.
6. Investigate and apply popular python libraries to conduct efficient data handling tasks..

Term Work:

1. Term work should consist of 10 experiments covering all modules.


2. Journal must include at least 2 assignments on content of theory and practical
of “Operating System”
3. The final certification and acceptance of term work ensures that satisfactory
performance of laboratory work and minimum passing marks in term work.
4. Total 25 Marks (Experiments: 15-marks, Attendance Theory& Practical: 05-
marks, Assignments: 05-marks)

Practical & Oral:


Oral & Practical exam Based on the entire syllabus of VSEC202 Python Programming.

35
EXPERIMENT NO:-1

Program 1.1
Aim:- Write A Python Program To Generate Personalized Greetings

Code:
print("Personalised Greeting")
DAY=input("HOW WAS YOUR DAY:")
print("YOUR DAY WAS :",DAY)

Output:-

Program 1.2

Aim:- Write A Python Program To Calculate Area Rectangle

Code:-
length=int(input("ENTER THE LENGTH:"))
breadth=int(input("ENTER THE BREADTH:"))
area=length*breadth
print("AREA OF RECTANGLE IS :",area)

Output:-

Program 1.3

Aim:- Write A Python Program To Calculate Area of Triangle.

Code:-
base=int(input("ENTER THE BASE:"))
height=int(input("ENTER THE HEIGHT:"))
area=0.5*base*height
print("THE AREA OF TRIANGLE IS :",area)

36
Output:-

Program 1.4

Aim:- Write A Python Program To Calculate Area Circle.

Code:-
r=int(input("enter the radius of circle:"))
a=3.14*r*r
print("The Area of Circle is :",a)

Output:-

Program 1.5

Aim: - Write A Python Program To Convert Rupees into Dollar.

Code:-
rupees=float(input("enter rupees:"))
dollar=rupees/81.86
print("The Dollar is:",dollar)

Output:-

Program 1.6

Aim:- Write A Python Program To Convert fahrenheit into degree celcius.

Code:-

f=float(input("enter temperature in farheinite:"))


c=(f-32)*(5/9)
print("The conversion of farheinite into degree celcius is:",c)

37
Output:-

Program 1.7

Aim:- Write A Python Program To convert inches into feet.

Code:-
inches=float(input("ENTER THE MEASURE IN INCHES:"))
feet=inches/12
print("THE MEASURE IN FEET IS:",feet)

Output:-

Program 1.8

Aim:-Write a program to calculate simple interest.

Code:-
P=int(input("Enter the principle ammount:"))
N=int(input("Enter the year:"))
R=float(input("Enter the rate of principle interest:"))
si=(P*N*R/100)
print("Simple interest = ",si)

Output:-

38
Program 1.9

Aim:- Write a python program perform addition, subtraction,multiplication and division.

Code:-
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
print("Addition is:",a+b)
print("Subtraction is:",a-b)
print("Multiplication is:",a*b)
print("Division is :",float(a/b))

Output:-

Program 1.10
Aim:-Write a program to calculate gross salary of an employee take theBasic salary (BS) as
an input from the user and calculate DA=70% of BS, HRA=10% of BS, and TA=30% of
BS and calculate gross salary.

Code:-
basicsalary=float(input("ENTER THE BASIC SALARY:"))
da=0.7*basicsalary
hra=0.1*basicsalary
ta=0.3*basicsalary
grosssalary=basicsalary+da+ta+hra
print("THE GROSS SALARY IS :",grosssalary)

Output:

Conclusion: - Thus we have implemented understanding of basic programming


constructs from C to Python.

39
EXPERIMENT NO:-2

Task List Manager


Program 2.1

Aim:- Develop a Python program to manage a task list using lists and tuples, including
adding, removing, updating, and sorting tasks.
Code:-
l=[10,20,30,40,50] #To create a list
print(l)
print(l[0]) #To access the element in the list
l=[15,25,35,45,55]
print(l[1:4]) #To access certain elements in the list
l=[12,26,39,41,53]
l[0]=80 #To access specific element in the list
print(l)
l=[14,23,38,47,50]
l[1]=[5,85] #To add elements in the list
print(l)
l=[13,60,31,44,53]
l.append(50) #To append element in the list
print(l)
l=[21,43,55,67,78]
l.extend([70,80]) #To extend elements in the list
print(l)
l=[30,20,10,5,2]
l.sort() #To sort elements in the list
print(l)
l=[40,20,10,5,2]
l.reverse() #To reverse the elements in the list
print(l)
l=[18,66,44,24,12]
l.pop() #To POP element from the list
print(l)
l.remove(66) #To remove element from the list
print(l)
del l[0] #To delete element from the list
print(l)

Output:-

31
0
Program 2.2

#Creating a tuple variable


std_detail= ("Arya Naik","30","A","A2")
print(std_detail)
#Tuple Assignment
(name, roll_no, div, batch)=std_detail
print(name)
print(roll_no)
print(div)
print(batch)
#Accessing the value in the tuple
t=(10, 20, 30, 40, 50)
print(t[3])
print(t[1:4]) #including 1 & excluding 4
#Add / Update elements in the tuple
'''Tuple is itself an unchangable data structure i.e. you can't add or update an element of
tuple'''
'''In order to change a value, we can convert tuple into the list & make necessary changes'''
tup=(10, 20, 30, 40, 50)
l=list(tup)
l[2]=80
updated_tuple= tuple(l)
print(updated_tuple)
#Deleting the entire tuple
t1= (10, 20, 30, 40, 50)
del t1
#print(t1) #this will throw an error since the tuple t1 has been completely deleted and does
not exist
#Maximum & Minimum values of tuple
print(max(t))
print(min(t))

Output:-

Conclusion:-Thus we have developed a Python program to manage a task list using lists and
tuples, including adding, removing, updating, and sorting tasks

31
1
EXPERIMENT NO:-3

Student Enrollment Manager

Program 3.1

Aim:- Create a Python code to demonstrate the use of sets and perform set operations
(union, intersection, difference) to manage student enrollments in multiple courses /
appearing for multiple entrance exams like CET, JEE, NEET etc.

Code:-

#Create set to manage student enrollment in multiple courses for multiple exams

CET={"Arya Naik" , "Harsh Kasare","Siddhi Masal"}


JEEE={"Arya Naik", "Harsh Kasare","Siddhi Masal","Aditya Shetty"}
NEET={"Siddhi Masal","Harsh Kasare"}

all_students=set.union(JEEE|CET|NEET)
print("Total students registered for entrance exam this year:\n", all_students)

common= (JEEE&CET&NEET)
print("Student enrolled in all three exams:\n", common)

unique=(JEEE-CET-NEET)
print("Student enrolled in only one exam:\n", unique)

unique=(JEEE^CET^NEET)
print("Student enrolled in all or only one exam:\n", unique)

Output:-

Conclusion:-Thus we have developed python code to demonstrate the use of sets and
perform set operations (union, intersection, difference).

31
2
EXPERIMENT NO:-4

Student Record Keeper

Program 4.1

Aim:- Write a Python program to create, update, and manipulate a dictionary of student
records, including their grades and attendance.

Code:-

student={"Name":"n", "Grade":"a" , "Attendence":"c"}


a=(input("Enter the Name:"))
b=(input("Enter the Gade:"))
c=(input("Enter the Attendence:"))
student["Name"]=a
student["Grade"]=b
student["Attendence"]=c
print(student)
d=(input("Name After update:"))
student["name"]=d
print(student)

Output:-

Conclusion:-Thus we have implemented Python program to create, update, and manipulate


a dictionary of student records, including their grades and attendance.

31
3
EXPERIMENT NO:-5

Number Type Identifier

Program 5.1

Aim:-Develop a Python program that takes a numerical input and identifies whether it is
even or odd, utilizing conditional statements and loops

Code:-

num=int(input("Enter a number :"))


if(num%2==0):
print("Number is even")
else:
print("Number is odd")

Output:-

Conclusion:-Thus we have implemented Python program that takes a numerical input and
identifies whether it is even or odd, utilizing conditional statements and loops.

31
4
EXPERIMENT NO:-6

Factorial Generator

Program 6.1

Aim:- Design a Python program to compute the factorial of a given integer N.

Code:-
f=1
i=1
n=int(input("Enter the number:"))
while i<=n:
f=f*i
i=i+1
print(f)

Output:-

Program 6.2

Aim:- Write a program to calculate factorial of any number using for loop.

Code:-
f=1
n=int(input("Enter a number:"))
for i in range (1,n+1):
f=f*i
print(f)

Output:-

Conclusion:-Thus we have implemented Python program to compute the factorial of a


given integer N.

31
5
EXPERIMENT NO:-7

Prime Number Analyzer

Program 7.1

Aim:-Using function, write a Python program to analyze the input number is prime or not

Code:-

n=int(input("Enter the no"))


def prime():
c=0
for i in range (2,n):
if (n%i==0):
c=c+1
break
if(c==0 and n!=1):
print ("Prime")
else :
print("not prime")
prime()

Output:-

Conclusion:-Thus we have implemented Python program to analyze the input number is


prime or not

31
6
EXPERIMENT NO:-8

Simple Calculator Using Functions

Program 8.1
Aim:-Implement a simple Python calculator that takes user input and performs basic
arithmetic operations (addition, subtraction, multiplication, division) using functions.

Code:-
x=int(input("Enter 1st number")
y=int(input("Enter 2nd number"))
def add():
z=x+y
print(z)
add()
def sub():
z=x-y
print(z)
sub()
def mul():
z=x*y
print(z)
mul()
def div():
z=x/y
print(z)
div()
Output:-

Conclusion:- Thus we have implemented python programs for understanding of


functions.

31
7
EXPERIMENT NO:-9

Extracting Words from Text File

Program 9.1
Aim:- Develop a Python program that reads a text file and prints words of specified lengths
(e.g., three, four, five, etc.) found within the file

Code:-

f="word.txt"
l=w=c=0
with open (“f ",r") as file:
for line in file:
l=l+1
w=w+len(line.split())
c=c+len(line)
print(l)
print(w)
print(c)

Output:-

Conclusion:- Thus we have implemented python programs for that reads a text file and
prints words of specified lengths.

31
8
EXPERIMENT NO:-10
Building an Executable File

Aim:- Create a executable file for any program developed in earlier practical

Steps:-
Step 1:- Open Command Prompt and write cd/

Step 2:- Enter this command in Command Prompt to install pip


py -m pip install --upgrade pip
Step 3:- After the installation is complete,Open File Explorer and
Go to Folder where the Python file is present ,Copy the path of
that folder
Step 4:- Write cd with below path on command prompt.
C:\Users\Lab10_20\AppData\Local\Programs\Python\Python313\Scripts

Step 5:-Write command pip install pyinstaller

Step 6:- Save the python program file word.py in the path -
C:\Users\Lab1020\AppData\Local\Programs\Python\Python313\Scripts
Step 7:- Run the command pyinstaller -F word.py
Step8:- The executable file has been created now, to check:
Open the Folder “dist”

Output:-

Conclusion:- Thus we have created a executable file for any program developed in
earlier practical

31
9
EXPERIMENT NO:-11

Basic Exception Handling

Program 11.1

Aim:- Write a Python program that takes two numbers as input and performs division.
Implement exception handling to manage division by zero and invalid input errors
gracefully.

Code:-
try:
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
result = num1 / num
print(result)
except ValueError as e:
print("Invalid Input Please Input Integer...")
except ZeroDivisionError as e:
print(e)

Output:

Conclusion:- Thus we have implemented Python program for exception handlilng.

32
0
32
1

You might also like