Module 4 –Writing Functions in Python
Atul Bengeri
Sunday, December 11, 2022
Coverage
‐ Recap
‐ Python Libraries
‐ Functions & Arguments
Recap
Recap
Recap
Recap
Predictive Modeling
Recap
Data Visualization
Recap
Programming
A process of forming/creating a set of step-by-step instructions that convey to a computer
what and how to perform a task.
https://www.khanacademy.org/computing/computer-programming/programming/intro-to-programming/v/programming-intro
Recap
Python Variables
A variable is initially declared to have a specific data type, and any value assigned to it during its lifetime
must always have that type.
Data Types:
Integer, Long Integer, Float, and String.
Integers are used to define numeric values;
Long Integers are used for defining integers with bigger lengths than a normal Integer.
Floats are used for defining decimal values, and
Strings are used for defining characters.
Recap
Data Structures
‐ Data Structures are fundamentals of any programming
language
‐ Objects/Structures that can hold some data together
‐ Data structure is a way of organizing the data in a proper
format, which makes it easy to access and modify the data
at run time.
‐ Data structure is a way of organizing data and establishing
a relationship between them.
Recap
Recap
1. A basic library Python for data science.
2.Indexing, manipulation, renaming, sorting, merging of data frames
3.Update, add, delete columns from a database
4.Detection of missing files and missing data management (null, na)
5.Graphical representation of data
1.Basic slicing and advanced indexing
2.Basic array operations: add, multiply, cut, sort, index
3.Advanced table operations: stack tables split into sections
4.Working with linear algebra
1.Uses arrays as the basic data structure
2.Common scientific programming tasks such as linear algebra, integration,
calculus, ordinary differential equations, and signal processing
1.The plotting library that provides an object-oriented API for integrating plots into applications.
2. Matplotlib can represent the data in several visualizations, we can plot Histograms, bar graphs, scatter
diagrams, area graphs, pie charts and more.
1.Data visualization library which provides a high-level interface to create attractive and informative
statistical graphs
2. Seaborn provides a variety of visualization models that are less complex and with less syntax.
1. Scikit Learn focuses on data modeling. It provides a range of supervised & unsupervised learning algorithms.
2. Classification: Spam detection, image recognition
3. Grouping
4. Regression: customer segmentation, a grouping of experience results
5. Dimensional reduction: Visualization, Increased efficiency
6. Model choice: Improved accuracy through parameter adjustment
1. It is an artificial intelligence library that helps developers create large-scale neural networks with many layers
2. Makes it easy to build deep learning models and enables easy deployment of ML-powered applications.
1. Keras is Tensorflow’s high-level API for the development and training of Deep Neural Network code.
2. It is an open-source neural network library in Python.
3. Statistical modeling, working with images and text is much easier, especially with the simplified coding for
deep learning.
1. It is the ultimate Python package that provides easy calculations for descriptive statistics and
estimation for statistical models.
2. Linear regression, Correlation, Ordinary Least Squares (OLS), Survival analysis, Generalized linear
models and Bayesian model, One-dimensional and two-dimensional analysis, Hypothesis testing
1. Used to create and display numbers, update numbers, hover over text for details.
2. Plotly also has the additional function of sending data to cloud servers
3. Very useful for Scientific graphics: Contour, Ternary, Log, Quiver, Carpet, Radar, Windrose heat maps and Polar
Plots
Function and Arguments
Functions Functions
Functions Functions
that are that are
that call that are
inbuilt in defined
itself Un-named
Python by users
input()
print() lambda arguments : expression
sum() def function_name (args):
min()
max()
Identifier
Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or
an underscore (_).
v all are valid example.
v An identifier cannot start with a digit.
v Keywords cannot be used as identifiers.
v Cannot use special symbols like !, @, #, $, % etc. in our identifier.
v Identifier can be of any length.
Modules
‐ A module is a “Python file” that contains code we can reuse in multiple Python programs.
‐ A module may contain functions, classes, lists, etc.
‐ Two types of Modules:
• Built-in Modules.
• User-defined Modules.
Package
https://learnpython.com/blog/python-modules-packages-libraries-frameworks/