0% found this document useful (0 votes)
8 views17 pages

Python Programming

Python, created by Guido van Rossum in 1991, prioritizes code readability and is widely used across various fields, including Biomedical Engineering and Electrical Engineering. It features a rich set of libraries for tasks such as data analysis, machine learning, and signal processing, making programming efficient. Python's dynamic typing and simple variable management further enhance its usability, while keywords and comments improve code clarity.

Uploaded by

Celin Narayanan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views17 pages

Python Programming

Python, created by Guido van Rossum in 1991, prioritizes code readability and is widely used across various fields, including Biomedical Engineering and Electrical Engineering. It features a rich set of libraries for tasks such as data analysis, machine learning, and signal processing, making programming efficient. Python's dynamic typing and simple variable management further enhance its usability, while keywords and comments improve code clarity.

Uploaded by

Celin Narayanan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

PYTHON PROGRAMMING

Introduction
• Python was created by Guido van
Rossum in 1991
• Further developed by the Python
Software Foundation.
• It was designed with focus on code
readability.
• Name origin:
British comedy series Monty
Python's Flying Circus.
• Latest Version:3.13
How it differs from other Programming Languages

• It’s simple to use because code is easier to write, understand


and maintain.
• Packed with features and supported by a wide range of
libraries and frameworks.
• Requires fewer lines of code compared to other programming
languages.
• Cross-platform, works on Windows, Mac and Linux without
major changes.
• Used by top tech companies like Google, Netflix and NASA.
LIBRARIES
• In Python, libraries are collections of pre-written code that provide
specific functionality, making programming more efficient and
convenient.
• They consist of modules—files containing Python definitions and
statements—that can be imported into your program to perform
tasks without writing code from scratch.
Key Features of Python Libraries:
• Reusable Code: Libraries save time by offering ready-made
solutions for common tasks.
• Wide Range of Applications: They support tasks like data analysis,
machine learning, web development, file handling, and more.
• Standard and Third-Party Libraries:
– Standard Library: Comes pre-installed with Python (e.g., math,
os, datetime).
– Third-Party Libraries: Created by the community and installed
via tools like pip (e.g., NumPy, Pandas, Requests).
Some key areas where Python is applied in Biomedical
Engineering (BME)

1. Medical Image Processing


Analyzing and processing medical images like MRI, CT, and X-rays.
Libraries: OpenCV, SimpleITK, scikit-image, Pydicom.
2. Signal Processing
Processing biomedical signals such as ECG, EEG, and EMG.
Libraries: SciPy, NumPy, PyWavelets.
3. Data Analysis and Visualization
Handling large datasets from clinical trials or experiments.
Libraries: Pandas, Matplotlib, Seaborn, Plotly.
4. Machine Learning and AI in Healthcare
Developing predictive models for disease diagnosis and treatment.
Libraries: scikit-learn, TensorFlow, PyTorch, Keras.
5. Bioinformatics
Analyzing genetic data, protein structures, and biological networks.
Libraries: Biopython, PyMOL.
6. Simulation and Modeling
Simulating physiological systems or drug delivery mechanisms.
Libraries: SimPy, SciPy.
7. Wearable Devices and IoT
Programming for health-monitoring devices and IoT-based healthcare
systems.
Libraries: Flask, Django, MQTT.
8. Robotics in Surgery
Programming robotic systems for precision surgeries.
Libraries: ROS (Robot Operating System).
Some key areas where python is widely used in EEE:
1. Circuit Design and Simulation
Python libraries like PySpice and SciPy are used for simulating and analyzing
electrical circuits.It helps in designing and testing circuits virtually before physical
implementation.
2. Signal Processing
Libraries such as NumPy, SciPy, and Matplotlib are used for analyzing and
processing signals.Applications include filtering, Fourier transforms, and spectral
analysis.
3. Control Systems
Python is used to model, simulate, and analyze control systems using libraries like
Control Systems Library.It aids in designing controllers like PID and state-space
models.
4. Power Systems Analysis
Python is employed for load flow analysis, fault analysis, and optimization in power
systems.Libraries like Pandapower are specifically designed for power system
simulations.
5. Embedded Systems and IoT
Python, especially MicroPython and CircuitPython, is used for programming
microcontrollers like Raspberry Pi and Arduino.
It is widely applied in IoT projects for automation and data collection.
6. Data Analysis and Machine Learning
Python is used for analyzing large datasets in EEE applications, such as energy
consumption or sensor data.
Libraries like TensorFlow, Keras, and Scikit-learn are used for predictive
modeling and machine learning.
7. Automation and Testing
Python scripts are used to automate repetitive tasks, such as testing circuits or
devices.
Tools like PyTest and PySerial are used for hardware testing and
communication.
8. Renewable Energy Systems
Python is applied in modeling and optimizing renewable energy systems like
solar panels and wind turbines.It helps in performance analysis and energy
forecasting.
Variables
In Python, variables are used to store data values that can be referenced and manipulated during
program execution.
A variable is essentially a name that is assigned to a value
Rules for Naming Variables:
Must start with a letter or an underscore (_).
Cannot start with a number.
Can only contain alphanumeric characters and underscores.
Case-sensitive (myVar and myvar are different).

Key Features of Python Variables:


Dynamic Typing: The type of a variable is determined at runtime.
X = 10 # Integer
X = "Hello" # Now a string
No Declaration Needed: Variables are created when you assign a value.
name = "Alice"
age = 25
Multiple Assignments:
Assign multiple variables in one line: a, b, c = 1, 2, 3
Assign the same value to multiple variables: x = y = z = 100
• variables are reference to Objects
A=5
A 5

B=5 B
• Examples of Variable Types:
• Integer: A = 42
• Float:pi = 3.14
• String: greeting = "Hello, Students!"
• Boolean:Is_active = True
Keywords
• Keywords in Python are reserved words that
have special meanings and serve specific
purposes in the language syntax.
• Python keywords cannot be used as the
names of variables, functions, and classes or
any other identifier.
The list of keywords are:

‘False', 'None', 'True',"__peg_parser__ 'and',
'as', 'assert', 'async', 'await', 'break',
'class', 'continue', 'def', 'del', 'elif', 'else',
'except', 'finally', 'for', 'from', 'global', 'if',
'import', 'in', 'is', 'lambda', 'nonlocal', 'not',
'or', 'pass', 'raise', 'return', 'try', 'while', 'with',
'yield'
Comments
• Comments in Python are the lines in the code that are
ignored by the interpreter during the execution of the
program.
• Comments enhance the readability of the code.
• Comment can be used to identify functionality or
structure the code-base.
• Comment can help understanding unusual or tricky
scenarios handled by the code to prevent accidental
removal or changes.
• Comments can be used to prevent executing any specific
part of your code, while making changes or testing.
• # I am single line comment

• """ Multi-line comment used


print("Python Comments") """
Input and Output

• input()
• print()

# taking two inputs at a time


x, y = input("Enter two values: ").split()
print("Number of boys: ", x)
print("Number of girls: ", y)

# taking three inputs at a time


x, y, z = input("Enter three values: ").split()
print("Total number of students: ", x)
print("Number of boys is : ", y)
print("Number of girls is : ", z)

You might also like