SlideShare a Scribd company logo
Python For Beginners
aliahuseyn[at]gmail[dot]com
Telegram Link (click me)
What is data type ?
Data type classification of data which tells the compiler or interpreter how the
programmer intends to use the data.
What is compiler/interpreter ?
Just Translator, all have to know about it.
Basic Data Types
Data Structures
A data structure is an abstract description of a way of organizing data
to allow certain operations on it to be performed efficiently.
Data Structure vs Data Type
A data type stores certain information without any semantics. A
data type can be an integer, a floating point, a string (basic data
types).
In a data structure information is, well, structured, and there are
certain ways you can access the information stored. For example in
a First In First Out (FIFO) queue you can add information to the
back and retrieve information from the front.
Python for beginners
Guido van Rossum
Now, it's my belief that Python is a lot easier than to teach
to students programming and teach them C or C++ or Java
at the same time because all the details of the languages
are so much harder. Other scripting languages really don't
work very well there either.
Data Types in Python
Built-in Data types
Sticking to the hierarchy scheme used in the official Python documentation
these are numeric types, sequences, sets and mappings (and a few more
not discussed further here).
Number Types
int long float complex
10 51924361L 0.0 3.14j
100 -0x19323L 15.20 45.j
-786 0122L -21.9 9.322e-36j
080 0xDEFABCECBDAECBFBAEL 32.3+e18 .876j
-0490 535633629843L -90. -.6545+0J
Variable & Variable Assignment
A variable is a location in memory used to store some data
(value).
We use the assignment operator (=) to assign values to a
variable. Any type of value can be assigned to any valid
variable.
Memory
Management In
Python
Holberton
s1 s2
del(s2)
Holberton
s1 s2
Reference Memory in
Python
Control Flow
Functions
A function is a block of organized, reusable code that is used to
perform a single, related action.
As you already know, Python gives you many built-in functions
like print(), etc. but you can also create your own functions.
These functions are called user-defined functions.
Data Structures
They are structures which can
hold some data together. In other
words, they are used to store a
collection of related data.
Sequence Types
list, dict, tuples, sets, strings
In computing, these types implement storage of data elements. Being
templates, they can be used to store arbitrary elements, such as
integers or custom classes. One common property of all sequential
types is that the elements can be accessed sequentially.
Accessing Values in
Strings
var1 = 'Hello World!'
var2 = "Python Programming"
print(var1[0]) # H
print(var2[1:5]) # ytho
Updating Strings
var1 = 'Hello World!'
var2 = var1[:6] + 'Python'
print(var2) # Hello Python
String Formatting Operator
print("My name is %s and weight is %d kg!" % ('Tofik', 120))
List Manipulation
colors = ['red', 'blue', 'green']
print(colors[0]) # red
print(colors[2]) # green
print(len(colors)) # 3
b = colors # Does not copy the list
Update & Delete List Elements
list = ['physics', 'chemistry', 1997, 2000]
# Update
print(list[2]) # 1997
list[2] = 2001
print(list[2]) # 2001
# Delete
print(list) # ['physics', 'chemistry', 2001, 2000]
del(list[2])
print(list) # ['physics', 'chemistry', 2000]
Control Flow #2 - For Loop Statement
Lists as an iterable:
list = ['physics', 'chemistry', 1997, 2000]
for x in list:
….print(x)
Strings as an iterable:
string = 'chemistry'
for x in string:
print(x)
Flat Sequences
Elements which has that subtype
are more compact, but they are
limited to holding primitive values
like characters, bytes and numbers.
Container Sequences
Hold references to the object they
contain, which may be of any type.
While flat sequences physically
store that value of each item within
its own memory space.
list, tuple, collections.deque ... str, bytes, array.array, ....
Mutable and Immutable Objects in Python
Simple put, a mutable object can be changed after it is
created, and an immutable object can’t. Objects of built-in
types like (int, float, bool, str, tuple) are immutable. Objects of
built-in types like (list, set, dict) are mutable.
Immutable Objects
It’s no big surprise that it fails since we just learnt immutable
objects cannot change their state.
Why Mutability Matters
Big bro of the list, Tuple.
A tuple is a sequence of immutable Python objects. Tuples are sequences, just
like lists. The differences between tuples and lists are, the tuples cannot be
changed unlike lists and tuples use parentheses, whereas lists use square
brackets.

More Related Content

What's hot (20)

PPTX
Data Types - Premetive and Non Premetive
Raj Naik
 
PPTX
Datastructures using c++
Gopi Nath
 
PPTX
DATA STRUCTURE
Rohit Rai
 
PDF
Introduction of data structures and algorithms
VinayKumarV16
 
PDF
Lecture1 data structure(introduction)
Taibah University, College of Computer Science & Engineering
 
PPT
Introduction to data structure
adeel hamid
 
PPTX
Introduction to data structure
NUPOORAWSARMOL
 
PDF
Data Structures
Prof. Dr. K. Adisesha
 
PPT
Data structure
Mohd Arif
 
PPTX
Introduction To Data Structures.
Education Front
 
PPTX
Presentation on Data Structure
A. N. M. Jubaer
 
PDF
Data structures
Naresh Babu Merugu
 
PPT
Data Structure In C#
Shahzad
 
PPT
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
PPTX
Data structure Assignment Help
JosephErin
 
PPT
1.1 binary tree
Krish_ver2
 
PPTX
R brownbag seminar 2.3
Muhammad Nabi Ahmad
 
PPT
data structure
hashim102
 
PPTX
Lecture 3.mte 407
rumanatasnim415
 
PDF
06 linked list
Rajan Gautam
 
Data Types - Premetive and Non Premetive
Raj Naik
 
Datastructures using c++
Gopi Nath
 
DATA STRUCTURE
Rohit Rai
 
Introduction of data structures and algorithms
VinayKumarV16
 
Introduction to data structure
adeel hamid
 
Introduction to data structure
NUPOORAWSARMOL
 
Data Structures
Prof. Dr. K. Adisesha
 
Data structure
Mohd Arif
 
Introduction To Data Structures.
Education Front
 
Presentation on Data Structure
A. N. M. Jubaer
 
Data structures
Naresh Babu Merugu
 
Data Structure In C#
Shahzad
 
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
Data structure Assignment Help
JosephErin
 
1.1 binary tree
Krish_ver2
 
R brownbag seminar 2.3
Muhammad Nabi Ahmad
 
data structure
hashim102
 
Lecture 3.mte 407
rumanatasnim415
 
06 linked list
Rajan Gautam
 

Similar to Python for beginners (20)

PDF
Data-structures7 class xii ashdshd hfuidshfkjhjsa ioh
KirtikaTomar1
 
PDF
Python Interview Questions PDF By ScholarHat
Scholarhat
 
PPTX
DS_PPT.pptx
MeghaKulkarni27
 
PPTX
Modulebajajajjajaaja shejjsjs sisiisi 4.pptx
NikhilKumar528311
 
ODP
James Jesus Bermas on Crash Course on Python
CP-Union
 
DOC
Bt0065
Simpaly Jha
 
DOC
B T0065
Simpaly Jha
 
PDF
Python for Dummies
Leonardo Jimenez
 
PPTX
Basic data types in python
sunilchute1
 
PPTX
Data -structures for class 12 , easy ppt
anikedheikhamsingh
 
ODP
C++ STL 概觀
PingLun Liao
 
PPTX
Address, Pointers, Arrays, and Structures.pptx
Dr. Amna Mohamed
 
PDF
LPR - Week 1
FaridRomadhana
 
PPTX
Bca ii dfs u-1 introduction to data structure
Rai University
 
PDF
Biopython: Overview, State of the Art and Outlook
Asociación Argentina de Bioinformática y Biología Computacional
 
PPTX
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
DOCX
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
faithxdunce63732
 
PPTX
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
AmrutaNavale2
 
PPTX
AI_2nd Lab.pptx
MohammedAlYemeni1
 
PPTX
Introduction to the basics of Python programming (part 3)
Pedro Rodrigues
 
Data-structures7 class xii ashdshd hfuidshfkjhjsa ioh
KirtikaTomar1
 
Python Interview Questions PDF By ScholarHat
Scholarhat
 
DS_PPT.pptx
MeghaKulkarni27
 
Modulebajajajjajaaja shejjsjs sisiisi 4.pptx
NikhilKumar528311
 
James Jesus Bermas on Crash Course on Python
CP-Union
 
Bt0065
Simpaly Jha
 
B T0065
Simpaly Jha
 
Python for Dummies
Leonardo Jimenez
 
Basic data types in python
sunilchute1
 
Data -structures for class 12 , easy ppt
anikedheikhamsingh
 
C++ STL 概觀
PingLun Liao
 
Address, Pointers, Arrays, and Structures.pptx
Dr. Amna Mohamed
 
LPR - Week 1
FaridRomadhana
 
Bca ii dfs u-1 introduction to data structure
Rai University
 
Biopython: Overview, State of the Art and Outlook
Asociación Argentina de Bioinformática y Biología Computacional
 
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
faithxdunce63732
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
AmrutaNavale2
 
AI_2nd Lab.pptx
MohammedAlYemeni1
 
Introduction to the basics of Python programming (part 3)
Pedro Rodrigues
 
Ad

Recently uploaded (20)

PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Ad

Python for beginners

  • 2. What is data type ? Data type classification of data which tells the compiler or interpreter how the programmer intends to use the data.
  • 3. What is compiler/interpreter ? Just Translator, all have to know about it.
  • 5. Data Structures A data structure is an abstract description of a way of organizing data to allow certain operations on it to be performed efficiently.
  • 6. Data Structure vs Data Type A data type stores certain information without any semantics. A data type can be an integer, a floating point, a string (basic data types). In a data structure information is, well, structured, and there are certain ways you can access the information stored. For example in a First In First Out (FIFO) queue you can add information to the back and retrieve information from the front.
  • 8. Guido van Rossum Now, it's my belief that Python is a lot easier than to teach to students programming and teach them C or C++ or Java at the same time because all the details of the languages are so much harder. Other scripting languages really don't work very well there either.
  • 9. Data Types in Python Built-in Data types Sticking to the hierarchy scheme used in the official Python documentation these are numeric types, sequences, sets and mappings (and a few more not discussed further here).
  • 10. Number Types int long float complex 10 51924361L 0.0 3.14j 100 -0x19323L 15.20 45.j -786 0122L -21.9 9.322e-36j 080 0xDEFABCECBDAECBFBAEL 32.3+e18 .876j -0490 535633629843L -90. -.6545+0J
  • 11. Variable & Variable Assignment A variable is a location in memory used to store some data (value). We use the assignment operator (=) to assign values to a variable. Any type of value can be assigned to any valid variable.
  • 15. Functions A function is a block of organized, reusable code that is used to perform a single, related action. As you already know, Python gives you many built-in functions like print(), etc. but you can also create your own functions. These functions are called user-defined functions.
  • 16. Data Structures They are structures which can hold some data together. In other words, they are used to store a collection of related data.
  • 17. Sequence Types list, dict, tuples, sets, strings In computing, these types implement storage of data elements. Being templates, they can be used to store arbitrary elements, such as integers or custom classes. One common property of all sequential types is that the elements can be accessed sequentially.
  • 18. Accessing Values in Strings var1 = 'Hello World!' var2 = "Python Programming" print(var1[0]) # H print(var2[1:5]) # ytho Updating Strings var1 = 'Hello World!' var2 = var1[:6] + 'Python' print(var2) # Hello Python String Formatting Operator print("My name is %s and weight is %d kg!" % ('Tofik', 120))
  • 19. List Manipulation colors = ['red', 'blue', 'green'] print(colors[0]) # red print(colors[2]) # green print(len(colors)) # 3 b = colors # Does not copy the list
  • 20. Update & Delete List Elements list = ['physics', 'chemistry', 1997, 2000] # Update print(list[2]) # 1997 list[2] = 2001 print(list[2]) # 2001 # Delete print(list) # ['physics', 'chemistry', 2001, 2000] del(list[2]) print(list) # ['physics', 'chemistry', 2000]
  • 21. Control Flow #2 - For Loop Statement Lists as an iterable: list = ['physics', 'chemistry', 1997, 2000] for x in list: ….print(x) Strings as an iterable: string = 'chemistry' for x in string: print(x)
  • 22. Flat Sequences Elements which has that subtype are more compact, but they are limited to holding primitive values like characters, bytes and numbers. Container Sequences Hold references to the object they contain, which may be of any type. While flat sequences physically store that value of each item within its own memory space. list, tuple, collections.deque ... str, bytes, array.array, ....
  • 23. Mutable and Immutable Objects in Python
  • 24. Simple put, a mutable object can be changed after it is created, and an immutable object can’t. Objects of built-in types like (int, float, bool, str, tuple) are immutable. Objects of built-in types like (list, set, dict) are mutable.
  • 25. Immutable Objects It’s no big surprise that it fails since we just learnt immutable objects cannot change their state.
  • 27. Big bro of the list, Tuple. A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.