Python
Fundamentals of Python
Session I
Norms
Take Notes! Do It With Me! Participate!
Agenda
1. What is python?
2. How to use python?
3. Variables!
4. Data types!
5. Expressions!
6. Strings!
What is Python?
Python!
Python is a high-level, object-oriented
programming language with built-in data
structures and dynamic semantics.
–It supports multiple programming
paradigms, such as structures, object-
oriented, and functional programming.
–Python was created by Guido van
Rossum.
Why should we use Python?
Why should we use Python?
● Known for being robust, scalable and
provides extensible visualization and
graphics options. Hence it’s widely
used in Data Science.
● Supports several popular libraries.
● Provides a vast collection of
frameworks that makes it much
easier for developers to develop web
applications.
Why should we use Python?
● Most preferred for Machine Learning
because of its simple syntax and its
support of several machine learning
libraries.
● A code developed in Python is often
compatible with most of the non-
native platforms. It can be integrated
with Java,.NET components, or C/C+
+ libraries.
How to work with Python?
Installation!
Firstly, install python and Anaconda
softwares on your desktop.
This is the site to install python ->
https://www.python.org/downloads/
This is the site to install Anaconda ->
https://www.anaconda.com/
Work with Python!
1. Install Python & Anaconda softwares.
2. Go to Anaconda prompt.
3. Search for jupyter notebook.
4. Create a new notebook and name it
accordingly.
5. Try writing a python program.
Work with Python!
For example:
Type
print("this is amazing!!!!")
Every programming language needs
to deal with lots of data & the
question arises is…
Where to store all these data?
What is a variable?
Variables!
● Containers for storing data values.
● Temporary storage spaces, where you store
data or values.
Python has no command for declaring a variable. A
variable is created when some value is assigned to
it.
The value assigned to a variable determines the
data type of that variable.
Every variable is associated with a data type.
Types of data!
1. Text Type: str
2. Numeric Types: int, float, complex
3. Sequence Types: list, tuple, range
4. Mapping Type: dict
5. Set Types: set, frozenset
6. Boolean Type: bool
7. Binary Types: bytes, bytearray, memoryview
Types of data!
Activity!
● Find the data type of following values.
1. 78951
2. 19.99
3. “HUMANS ARE WEIRD ”
What are Expressions?
Expressions!
The operators that are used to perform operations on variables and
values.
There are three main types of Operators:
1. Arithmetic operators
2. Comparison operators/ Relational Operators
3. Logical operators
Expressions!
Operator Name Example
1. Arithmetic operators: + Addition X+Y
– Subtraction X–Y
Arithmetic operators are used
* Multiplication X*Y
with numeric values to
/ Division X/Y
perform common % Modulus X%Y
mathematical operations ** Exponentiation X ** Y
// Floor division X // Y
Expressions!
Operator Name Example
2. Relational == Equal X == Y
Operators: != Not equal X != Y
> Greater than X>Y
Comparison operators are
< Less than X<Y
used to compare two
>= Greater than or equal X >= Y
values. to
<= Less than or equal to X <= Y
Expressions!
Operator Description Example
3. Logical Operators:
and Returns True if both X < 5 and X < 10
statements are true where X=3
Logical operators are => TRUE
used to combine or Returns True if one of the X < 5 or X < 2
statements is true where X= 3
conditional statements. => True
not Reverse the result, not(X < 5 and X <
returns False if the result 10) where X=3
is true => FALSE
Activity!
● Apply all the relational operators for the given
values
1. X = 9, Y = 7
2. X = 896, Y = 890
● Apply all the arithmetic operators for the
given values.
1. X = 56, Y = 89
2. X = 96, Y = 20
What are Strings?
Strings!
● An ordered sequence, can be
accessed using an index represented
by the array of numbers.
● Arrays are used to store multiple
values in one single variable.
● In python string is a sequence of characters. It is contained within
single or double or triple quotes. They can be spaces, digits or
special characters.
Strings!
Positive indexing
Strings!
Negative indexing
Strings!
● Strings are immutable, which means
the value in data type cannot be
updated.
● Strings help us in knowing the length
of an element.
● Square brackets can be used to
access elements of the string.
Strings!
Activity!
● Write a Python program to calculate the
length of a string “HELLO_WOLRD”
● Extract last 5 words of a string “HELLO
WORLD”
What we learnt today!
● What is python and how to use it?
● All about
○ Variables
○ Data types
○ Expressions
○ Strings
Time for Feedback!
1. Click on the feedback form link.
2. Enter your personal details.
3. Rate the session based on
a. Overall Experience
b. Trainer
c. Content
4. Then click on Submit…!
Doubts?
Key Takeaways
What is your one key takeaway from the session?