SlideShare a Scribd company logo
Python:
Basics (in Python)
AAA-Python Edition
Plan
●
1- Basic Operations and variables
●
2- Basic Types
●
3- Functions and white space formatting
●
4- Modules and Libraries
●
5- Examples of some Libraries
●
6- Installing Libraries in Google Colab
3
1-BasicOperations
Andvariables
[By Amina Delali]
●
To perform simple operations, you just have to type them:
Integer division/floored quotient
Modulus (remainder)
Exponent
4
1-BasicOperations
Andvariables
[By Amina Delali]
●
Other type of operations:
If 5 wasn’t greater
than 3, it would returned
False
Is 5 different
from 3
Is 5 equal to 3
The only case this expression is evaluated to False,
it’s when the two operands are evaluated to False
The only case this expression is evaluated to True,
it’s when the two operands are evaluated to True
5
1-BasicOperations
Andvariables
[By Amina Delali]
●
Table of precedence of some operators (increasing order)
To evaluate an expression with multiple operators,the “precedence” rule apply
Expression between parentheses is evaluated first:(-1+1)=0
Then the exponentiation is evaluated: 6**0=1
Then the multiplication is evaluated: 3*1=3
Then the addition is evaluated: 5+3=8
The full table can be seen at:
https://docs.python.org/3.6/reference/expressions.html#operator-precedence
or
and
not
< , <= , > ,
>= , != , ==
+, -
* , / , // , %
**
( )
Highest precedence
Operators in the same box
have same precedence
Operators in the same box group from left to right
(except for exponentiation **).For example, to evaluate 5 / 4 * 2 :
We start by: 5 / 4 = 1.25 (the most left operator)
Then: 1.25 * 2 = 2.5 (we continue with the following one)
6
1-BasicOperations
Andvariables
[By Amina Delali]
●
We can store values of expressions in “variables” with the
“assignment” statement:
Assignment statement
Variable name
●
Variable names have some mandatory characteristics
●
Composed of 1 word
●
Composed only by: letters, number or the
underscore character (_)
●
Can not start with a number
The value of “a” is 3,
and the value of “b” is 5
7
1-BasicOperations
Andvariables
[By Amina Delali]
●
We can assign one value to multiple variables
●
We can assign multiple values to multiples variables:
8
2-BasicTypes
[By Amina Delali]
● Numbers
●
Integer 5
-3
0
1000
●
Float 7.8
-3.156
0.0
●
Complex 5.3+2j
10+1J
●
A number can be:
Real part
Imaginary part
9
2-BasicTypes
[By Amina Delali]
Strings
●
String are text values written between quotes:
10
2-BasicTypes
[By Amina Delali]
Strings
●
With Strings, we can perform Concatenation and
Replication operations:
11
2-BasicTypes
[By Amina Delali]
●
Boolean
●
They have only two values: True and False
●
In a numeric context: True behaves like 1 and False like 0
●
The Boolean operators are : and, or, not
12
3-Functionsand
whitespace
formatting
[By Amina Delali]
●
Functions are a “reusable” block of code.
●
They can be “built-in” functions: already defned
●
They can be also “user-defned”: you can defne your own
functions.
●
Example of built-in functions:
Functions
Number of character of
string S1
13
3-Functionsand
whitespace
formatting
[By Amina Delali]
Functions
Convert j into a float
New line character
14
3-Functionsand
whitespace
formatting
[By Amina Delali]
User defined functions
White space formatting
●
Python uses indentation to define blocks of code
●
Blocks begin when the indentation increases
●
Blocks end when the indentation decreases
●
Whitespace is ignored inside parentheses and brackets
The block of code
is marked by a colon(:)
and its indentation
(the space before print)
Calling the function
(decreasing the indentation to terminate
The function definition block)
15
3-Functionsand
whitespace
formatting
[By Amina Delali]
●
Return statement
The function arguments
Keyword and default arguments
●
A function can return a value using the keyword “return”
The function returns the value
of a+b
●
In a function call, we can identify the arguments by their name.
●
In a function definition, the arguments can have a default value
they will be optional
16
3-Functionsand
whitespace
formatting
[By Amina Delali]
●
The default value of a third argument
So the argument is optional
The order of the arguments a and b
doesn’t matter, since they are identified
by their names
17
4-ModulesandLibraries
[By Amina Delali]
●
A module is a program that contains a related group of functions that can
be embedded in your programs
Module and Library
●
To use the functions module you have to use the “import” statement.
●
Other statement with import like “from” and “as” can be used
●
A set of modules define a Library
●
Python comes with a library called the standard library
●
To use an other library modules, you have to install the corresponding
library : a third-party library
18
4-ModulesandLibraries
[By Amina Delali]
Function “randint “from
module random
Only “randint” was
imported
The name of “randint” was replaced by “ri”
19
5-Examplesofsome
Libraries
[By Amina Delali]
● Third-party libraries
●
Numpy: is the fundamental package for scientific computing with
Python
●
Pandas: is an open source, BSD-licensed library providing high-
performance, easy-to-use data structures and data analysis tools for the
Python programming language.
●
Matpolotlib: is a Python 2D plotting library
●
Tensorflow: An open source machine learning framework for
everyone. It is a software library for high performance numerical
computation.
20
5-Examplesofsome
Libraries
[By Amina Delali]
●
Third-party libraries
●
Numpy:
21
5-Examplesofsome
Libraries
[By Amina Delali]
●
Third-party libraries
●
Matplotlib:
22
6-InstallingLibraries
inGoogleColab
[By Amina Delali]
! pip install
apt-get
After !apt-get update
From:( https://colab.research.google.com/notebooks/snippets/importing_libraries.ipynb)
References
●
Duchesnay Edouard and Löfstedt Tommy.Statistics and machine learning in python
release 0.2. On-line at ftp:
//ftp.cea.fr/pub/unati/people/educhesnay/pystatml/M1_IMSV/
StatisticsMachineLearningPythonDraft.pdf. Accessed on 23-09-2018.
●
Python Software Foundation. The python language reference. On-line
at https://docs.python.org/3.6/reference/index.html. Accessed on 23-09-2018.
●
Python Software Foundation. The python standard library. On-line at
●
https://docs.python.org/3.6/library/index.html. Accessed on 23-09-2018.
●
Joel Grus. Data science from scratch: frst principles with python. O’Reilly Media,
Inc, 2015.
●
J. D. Hunter. Matplotlib: A 2d graphics environment. Computing In Science &
Engineering, 9(3):90–95, 2007.
●
NumPy. Numpy. On-line at http://www.numpy.org/. Accessed on 23-09-2018.
References
●
pandas. pandas. On-line at https://pandas.pydata.org/. Accessed on
23-09-2018.
●
Chandat Sunny. Learn Python in 24 Hours. CreateSpace Independent
Publishing Platform, 2016.
●
Al Sweigart. Automate the boring stuf with Python: practical programming
for total beginners. No Starch Press, 2015.
●
TensorFlow. About tensorfow. On-line at https://www.tensorfow.
org/. Accessed on 23-09-2018.
RuleN°7
Thank
you!
FOR ALL YOUR TIME

More Related Content

PPTX
Functions
PPTX
Functional programming with Java 8
PDF
Java 8 by example!
PPTX
Functions in Python
PPTX
PHP = PHunctional Programming
PDF
(3) cpp procedural programming
PPTX
Functions in Python
PPTX
Functional Programming in JavaScript & ESNext
Functions
Functional programming with Java 8
Java 8 by example!
Functions in Python
PHP = PHunctional Programming
(3) cpp procedural programming
Functions in Python
Functional Programming in JavaScript & ESNext

What's hot (20)

PPTX
Function in C Programming
PDF
Java 8 Lambda Expressions & Streams
PDF
Functional programming in scala
PDF
Intro to JavaScript - Week 2: Function
PDF
Python recursion
PDF
Functional Programming in Ruby
PPTX
Dev Concepts: Functional Programming
PPTX
Function & Recursion
PPTX
Java 8 Functional Programming - I
PPTX
Function
PDF
Python algorithm
PDF
Functional go
PPTX
Functions in C
PPTX
Functional programming
PDF
VIT351 Software Development VI Unit1
PDF
Ruby Functional Programming
PPT
user defined function
PDF
Python functional programming
PPTX
Think in linq
PDF
Introduction to functional programming (In Arabic)
Function in C Programming
Java 8 Lambda Expressions & Streams
Functional programming in scala
Intro to JavaScript - Week 2: Function
Python recursion
Functional Programming in Ruby
Dev Concepts: Functional Programming
Function & Recursion
Java 8 Functional Programming - I
Function
Python algorithm
Functional go
Functions in C
Functional programming
VIT351 Software Development VI Unit1
Ruby Functional Programming
user defined function
Python functional programming
Think in linq
Introduction to functional programming (In Arabic)
Ad

Similar to Aaa ped-2- Python: Basics (20)

PPTX
pythontraining-201jn026043638.pptx
PDF
Functional programming in Scala
PPTX
Python training
PPTX
Python presentation of Government Engineering College Aurangabad, Bihar
PDF
Functions-.pdf
PDF
First Steps in Python Programming
PDF
Aaa ped-3. Pythond: advanced concepts
PPTX
Functional Programming.pptx
PDF
Dive into Python Functions Fundamental Concepts.pdf
PDF
Blueprints: Introduction to Python programming
PPTX
Chapter - 4.pptx
PPTX
Python intro
PPTX
Docketrun's Python Course for beginners.pptx
PPTX
Mastering Python lesson 4_functions_parameters_arguments
PDF
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
PDF
Functions
PDF
New c sharp4_features_part_i
PPTX
Introduction to Koltin for Android Part I
PPTX
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
pythontraining-201jn026043638.pptx
Functional programming in Scala
Python training
Python presentation of Government Engineering College Aurangabad, Bihar
Functions-.pdf
First Steps in Python Programming
Aaa ped-3. Pythond: advanced concepts
Functional Programming.pptx
Dive into Python Functions Fundamental Concepts.pdf
Blueprints: Introduction to Python programming
Chapter - 4.pptx
Python intro
Docketrun's Python Course for beginners.pptx
Mastering Python lesson 4_functions_parameters_arguments
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
Functions
New c sharp4_features_part_i
Introduction to Koltin for Android Part I
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
Ad

More from AminaRepo (20)

PDF
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
PDF
Aaa ped-22-Artificial Neural Network: Introduction to ANN
PDF
Aaa ped-21-Recommender Systems: Content-based Filtering
PDF
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
PDF
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
PDF
Aaa ped-18-Unsupervised Learning: Association Rule Learning
PDF
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
PDF
Aaa ped-16-Unsupervised Learning: clustering
PDF
Aaa ped-15-Ensemble Learning: Random Forests
PDF
Aaa ped-14-Ensemble Learning: About Ensemble Learning
PDF
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
PDF
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
PDF
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
PDF
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
PDF
Aaa ped-Data-8- manipulation: Plotting and Visualization
PDF
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
PDF
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
PDF
Aaa ped-5-Data manipulation: Pandas
PDF
Aaa ped-4- Data manipulation: Numpy
PDF
Aaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-16-Unsupervised Learning: clustering
Aaa ped-15-Ensemble Learning: Random Forests
Aaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
Aaa ped-5-Data manipulation: Pandas
Aaa ped-4- Data manipulation: Numpy
Aaa ped-1- Python: Introduction to AI, Python and Colab

Recently uploaded (20)

PDF
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
PDF
. Radiology Case Scenariosssssssssssssss
PDF
bbec55_b34400a7914c42429908233dbd381773.pdf
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PDF
The scientific heritage No 166 (166) (2025)
PPTX
neck nodes and dissection types and lymph nodes levels
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PPTX
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PPTX
Introduction to Cardiovascular system_structure and functions-1
PPTX
ECG_Course_Presentation د.محمد صقران ppt
PPTX
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PPT
protein biochemistry.ppt for university classes
PDF
Biophysics 2.pdffffffffffffffffffffffffff
DOCX
Viruses (History, structure and composition, classification, Bacteriophage Re...
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
PDF
AlphaEarth Foundations and the Satellite Embedding dataset
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PPTX
Cell Membrane: Structure, Composition & Functions
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
. Radiology Case Scenariosssssssssssssss
bbec55_b34400a7914c42429908233dbd381773.pdf
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
The scientific heritage No 166 (166) (2025)
neck nodes and dissection types and lymph nodes levels
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
Introduction to Cardiovascular system_structure and functions-1
ECG_Course_Presentation د.محمد صقران ppt
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
protein biochemistry.ppt for university classes
Biophysics 2.pdffffffffffffffffffffffffff
Viruses (History, structure and composition, classification, Bacteriophage Re...
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
AlphaEarth Foundations and the Satellite Embedding dataset
Phytochemical Investigation of Miliusa longipes.pdf
Cell Membrane: Structure, Composition & Functions

Aaa ped-2- Python: Basics

  • 2. Plan ● 1- Basic Operations and variables ● 2- Basic Types ● 3- Functions and white space formatting ● 4- Modules and Libraries ● 5- Examples of some Libraries ● 6- Installing Libraries in Google Colab
  • 3. 3 1-BasicOperations Andvariables [By Amina Delali] ● To perform simple operations, you just have to type them: Integer division/floored quotient Modulus (remainder) Exponent
  • 4. 4 1-BasicOperations Andvariables [By Amina Delali] ● Other type of operations: If 5 wasn’t greater than 3, it would returned False Is 5 different from 3 Is 5 equal to 3 The only case this expression is evaluated to False, it’s when the two operands are evaluated to False The only case this expression is evaluated to True, it’s when the two operands are evaluated to True
  • 5. 5 1-BasicOperations Andvariables [By Amina Delali] ● Table of precedence of some operators (increasing order) To evaluate an expression with multiple operators,the “precedence” rule apply Expression between parentheses is evaluated first:(-1+1)=0 Then the exponentiation is evaluated: 6**0=1 Then the multiplication is evaluated: 3*1=3 Then the addition is evaluated: 5+3=8 The full table can be seen at: https://docs.python.org/3.6/reference/expressions.html#operator-precedence or and not < , <= , > , >= , != , == +, - * , / , // , % ** ( ) Highest precedence Operators in the same box have same precedence Operators in the same box group from left to right (except for exponentiation **).For example, to evaluate 5 / 4 * 2 : We start by: 5 / 4 = 1.25 (the most left operator) Then: 1.25 * 2 = 2.5 (we continue with the following one)
  • 6. 6 1-BasicOperations Andvariables [By Amina Delali] ● We can store values of expressions in “variables” with the “assignment” statement: Assignment statement Variable name ● Variable names have some mandatory characteristics ● Composed of 1 word ● Composed only by: letters, number or the underscore character (_) ● Can not start with a number The value of “a” is 3, and the value of “b” is 5
  • 7. 7 1-BasicOperations Andvariables [By Amina Delali] ● We can assign one value to multiple variables ● We can assign multiple values to multiples variables:
  • 8. 8 2-BasicTypes [By Amina Delali] ● Numbers ● Integer 5 -3 0 1000 ● Float 7.8 -3.156 0.0 ● Complex 5.3+2j 10+1J ● A number can be: Real part Imaginary part
  • 9. 9 2-BasicTypes [By Amina Delali] Strings ● String are text values written between quotes:
  • 10. 10 2-BasicTypes [By Amina Delali] Strings ● With Strings, we can perform Concatenation and Replication operations:
  • 11. 11 2-BasicTypes [By Amina Delali] ● Boolean ● They have only two values: True and False ● In a numeric context: True behaves like 1 and False like 0 ● The Boolean operators are : and, or, not
  • 12. 12 3-Functionsand whitespace formatting [By Amina Delali] ● Functions are a “reusable” block of code. ● They can be “built-in” functions: already defned ● They can be also “user-defned”: you can defne your own functions. ● Example of built-in functions: Functions Number of character of string S1
  • 14. 14 3-Functionsand whitespace formatting [By Amina Delali] User defined functions White space formatting ● Python uses indentation to define blocks of code ● Blocks begin when the indentation increases ● Blocks end when the indentation decreases ● Whitespace is ignored inside parentheses and brackets The block of code is marked by a colon(:) and its indentation (the space before print) Calling the function (decreasing the indentation to terminate The function definition block)
  • 15. 15 3-Functionsand whitespace formatting [By Amina Delali] ● Return statement The function arguments Keyword and default arguments ● A function can return a value using the keyword “return” The function returns the value of a+b ● In a function call, we can identify the arguments by their name. ● In a function definition, the arguments can have a default value they will be optional
  • 16. 16 3-Functionsand whitespace formatting [By Amina Delali] ● The default value of a third argument So the argument is optional The order of the arguments a and b doesn’t matter, since they are identified by their names
  • 17. 17 4-ModulesandLibraries [By Amina Delali] ● A module is a program that contains a related group of functions that can be embedded in your programs Module and Library ● To use the functions module you have to use the “import” statement. ● Other statement with import like “from” and “as” can be used ● A set of modules define a Library ● Python comes with a library called the standard library ● To use an other library modules, you have to install the corresponding library : a third-party library
  • 18. 18 4-ModulesandLibraries [By Amina Delali] Function “randint “from module random Only “randint” was imported The name of “randint” was replaced by “ri”
  • 19. 19 5-Examplesofsome Libraries [By Amina Delali] ● Third-party libraries ● Numpy: is the fundamental package for scientific computing with Python ● Pandas: is an open source, BSD-licensed library providing high- performance, easy-to-use data structures and data analysis tools for the Python programming language. ● Matpolotlib: is a Python 2D plotting library ● Tensorflow: An open source machine learning framework for everyone. It is a software library for high performance numerical computation.
  • 22. 22 6-InstallingLibraries inGoogleColab [By Amina Delali] ! pip install apt-get After !apt-get update From:( https://colab.research.google.com/notebooks/snippets/importing_libraries.ipynb)
  • 23. References ● Duchesnay Edouard and Löfstedt Tommy.Statistics and machine learning in python release 0.2. On-line at ftp: //ftp.cea.fr/pub/unati/people/educhesnay/pystatml/M1_IMSV/ StatisticsMachineLearningPythonDraft.pdf. Accessed on 23-09-2018. ● Python Software Foundation. The python language reference. On-line at https://docs.python.org/3.6/reference/index.html. Accessed on 23-09-2018. ● Python Software Foundation. The python standard library. On-line at ● https://docs.python.org/3.6/library/index.html. Accessed on 23-09-2018. ● Joel Grus. Data science from scratch: frst principles with python. O’Reilly Media, Inc, 2015. ● J. D. Hunter. Matplotlib: A 2d graphics environment. Computing In Science & Engineering, 9(3):90–95, 2007. ● NumPy. Numpy. On-line at http://www.numpy.org/. Accessed on 23-09-2018.
  • 24. References ● pandas. pandas. On-line at https://pandas.pydata.org/. Accessed on 23-09-2018. ● Chandat Sunny. Learn Python in 24 Hours. CreateSpace Independent Publishing Platform, 2016. ● Al Sweigart. Automate the boring stuf with Python: practical programming for total beginners. No Starch Press, 2015. ● TensorFlow. About tensorfow. On-line at https://www.tensorfow. org/. Accessed on 23-09-2018.