Satyam Pthon
Satyam Pthon
Laboratory Manual
Python Programming
NAME: SATYAM GUPTA
ROLL NO: A 426
BATCH: SA-2
DEPARTMENT OF MECHANICAL ENGINEERING
2024-25
Vision
To be the department committed to nurture student cantered learning
experience through outcome and skill based transformative education to create
technocrats and leaders for the service of society and nation.
Python
Programming Lab
1
DEPARTMENT OF MECHANICAL ENGINERING
Mission
1. To provide an educational experience that transforms students into
competent Mechanical Engineering professionals and responsible
citizens.
2. To provide an academic ambiance in the department that flourish new
ideas, research interest, leadership, team spirit and ethics.
3. To strive for excellence in faculty and students of the department by
encouraging skills development, creativity, capability and applicability.
4. To join the institute in its contribution to the service of society by
participation of faculty, staff and students in socio-economic and
sociocultural activities.
5. To work on Research and Development projects and offer consultancies
in Mechanical Engineering and also in the interdisciplinary areas to
strengthen the education and research ecosystem.
6. To establish the linkages with apex educational and research institutions
at national level and support the institute to emerge into a Centre of
Excellence.
Python Programming
SE (Mechanical), Semester – IV
Course Objectives:
Python
Programming Lab
2
DEPARTMENT OF MECHANICAL ENGINERING
3. Develop and execute Python program for specific applications
4. Develop and build Python program to solve real world engineering
problems.
5. Prepare a report on case studies selected Lab Outcomes:
Python
MEL403 -- 02 -- 01 01
Programming
Mrs. Sowmyashree
Lab In charge
List of Experiments
Exp. Title of
Subtitles Page No.
No. Experiments
Python
Programming Lab
3
DEPARTMENT OF MECHANICAL ENGINERING
a) Introduction to Python and its applications
8-11
a) if statement
83-84
Python
Programming Lab
4
DEPARTMENT OF MECHANICAL ENGINERING
6 Programs to b) if …. else statement
84-85
understand
c) if..elif…else statement
85-86
Program to a)
while loop 92-95
understand Loops
and Loop control b) For loop 95-98
statements c) range() function 98-99
d)
7 Nested Loops 100
e)
Loop control statement :break 101-102
f)
Loop control statement :continue 102-103
g)
Loop control statement :pass 103-104
Programs to a) A simple function
understand b) Pass by value
8 Functions in Python c) Pass by Reference
106-115
d) Default arguments
e) Keyword arguments
f) Lamba expressions
Programs to
understand Object Programs to understand Object oriented
oriented Programming (OOP) concepts: classes, objects
Programming a) and methods
9
(OOP) concepts: 117-125
classes, objects and
methods
Programs to a)
Program to understand file open/read/close
understand 127-132
different file functions
10
handling operations b)
Program to understand file
132-135
write/append/create/delete functions
Python
Programming Lab
5
DEPARTMENT OF MECHANICAL ENGINERING
Sample case studies 1. A case study on –solving Linear Differential
Equation of Newton’s Law of Cooling using 136-142
python programming
Experiment Number: 01
Name of Experiment: Introduction and Installation of
Python
Date of Performance: 13/01/2025
Date of Submission: 20/01/2025
Python
Programming Lab
6
DEPARTMENT OF MECHANICAL ENGINERING
Experiment no. 1
Introduction and Installation of python
Aim:
Python is a general purpose programming language which can be used for almost anything
may it to be develop webpages or for machine learning or any sort of simple application.
History of Python:
In 1980’s Guido Van Rossum wanted to make a language that is beautiful to look at and easy
for everybody to read. As a hobby he started to make a language which uses indentations
instead of braces, as a result code becomes readable and named flying circus creator “Monty
python” it Python his favourite show. Created in 1989 and Released In 1991. Gaining
popularity for ML and AI as python makes code easy and efficient
Formally, Python is High level interpreted language which has easy syntax and dynamic
semantics
• High level: python derives components from natural language humans use to
communicate with each other
• Interpreted: python code is compiled line by line which makes debugging errors
much more easier and efficient ( but much more slower than other programming
languages)
• Dynamic semantics: do not have to initialize anything. It happens automatically
during runtime.
Python
Programming Lab
7
DEPARTMENT OF MECHANICAL ENGINERING
Features of Python
Python
Programming Lab
8
DEPARTMENT OF MECHANICAL ENGINERING
Applications of Python Programming:
2. Game Development
Python is also used in the development of interactive games. There are libraries such as
PySoy which is a 3D game engine supporting Python 3, PyGame which provides functionality
and a library for game development. Games such as Civilization-IV, Disney’s Toontown
Online, Vega Strike etc. have been built using Python.
You can even visualize the data libraries such as Matplotlib, Seaborn, which are helpful in
plotting graphs and much more. This is what Python offers you to become a Data Scientist.
5. Desktop GUI
We use Python to program desktop applications. It provides the Tkinter library that can be
used to develop user interfaces. There are some other useful toolkits such as the wxWidgets,
Kivy, PYQT that can be used to create applications on several platforms. You can start out
with creating simple applications such as Calculators, To-Do apps and go ahead and create
much more complicated applications.
Python
Programming Lab
9
DEPARTMENT OF MECHANICAL ENGINERING
6. Web Scraping Applications
Python is a savior when it comes to pull a large amount of data from websites which can then
be helpful in various real-world processes such as price comparison, job listings, research
and development and much more. Python has BeautifulSoup which we use to pull such data.
Here’s a full-fledged guide to learn Web scraping with Python.
7. Business Applications
Business Applications are different than our normal applications covering domains such as
e-commerce, ERP and many more. They require applications which are scalable, extensible
and easily readable and Python provides us with all these features. Platforms such as Tryton
is available to develop such business applications.
We use Python to develop applications that can multi-task and also output media. Video and
audio applications such as TimPlayer, Cplay have been developed using Python libraries.
They provide better stability and performance in comparison to other media players.
9. CAD Applications
Computer-Aided Designing is quite challenging to make as many things have to be taken care
of. Objects and their representation, functions are just the tip of the iceberg when it comes to
something like this. Python makes this simple too and the most well-known application for
CAD is Fandango.
Python is based on C which means that it can be used to create Embedded C software for
embedded applications. This helps us to perform higher-level applications on smaller devices
which can compute Python.The most well-known embedded application could be the
Raspberry Pi which uses Python for its computing. We can also use it as a computer or like a
simple embedded board to perform high-level computations.
Python
Programming Lab
10
DEPARTMENT OF MECHANICAL ENGINERING
Step 2: Once downloaded run Python installer. Check add python to path and click install now.
Python
Programming Lab
11
DEPARTMENT OF MECHANICAL ENGINERING
Step 3: Once installation is done then open Python shell or IDLE (development
environment for python) from start menu/search bar
Python
Programming Lab
12
DEPARTMENT OF MECHANICAL ENGINERING
Script Mode Programming
Invoking the interpreter with a script parameter begins execution of the script and
continues until the script is finished
Python files have extension .py
Let us write a simple Python program in a script. Python files have extension .py.
Type the following source code in a 1.py file
Python
Programming Lab
13
DEPARTMENT OF MECHANICAL ENGINERING
Python
Programming Lab
14
DEPARTMENT OF MECHANICAL ENGINERING
Python
Programming Lab
15
DEPARTMENT OF MECHANICAL ENGINERING
c) Installation of Python programming environment: Installation of Anaconda
Navigator
Why anaconda?
• anaconda comes with a lot of libraries so you don’t have to install those libraries or
packages again so it is very user friendly for beginners
• with anaconda there comes an IDE known as Spyder so we will be using Spyder Step
Python
Programming Lab
17
DEPARTMENT OF MECHANICAL ENGINERING
Step 5: click on downloaded fine and install
Step 5: click on next after choosing right options , at the end of installation click finish.
Python
Programming Lab
18
DEPARTMENT OF MECHANICAL ENGINERING
Python
Programming Lab
19
DEPARTMENT OF MECHANICAL ENGINERING
Python
Programming Lab
20
DEPARTMENT OF MECHANICAL ENGINERING
Spyder IDE
Python
Programming Lab
21
DEPARTMENT OF MECHANICAL ENGINERING
Python
Programming Lab
22