SlideShare a Scribd company logo
國立臺北護理健康大學 NTUHS
Python Introduction
Orozco Hsu
2021-11-01
1
About me
• Education
• NCU (MIS)、NCCU (CS)
• Work Experience
• Telecom big data Innovation
• AI projects
• Retail marketing technology
• User Group
• TW Spark User Group
• TW Hadoop User Group
• Taiwan Data Engineer Association Director
• Research
• Big Data/ ML/ AIOT/ AI Columnist
2
Tutorial
Content
3
Python Programming Basics for Beginners
Homework
Brief introduction
Python basic tutorials
Code
• Download code
• https://github.com/orozcohsu/ntunhs_2021.git
• Folder
• 20211101_inter_master
4
What can Python do?
•Console application
•Desktop application
•Web application
•Mobile application
•Machine Learning
•Data Science
•IOT application
•And many more …
5
Python version
• Python 0.9.0 - February 20, 1991
• Python 0.9.1 - 1991
• Python 0.9.2 - 1991
• Python 1.0 - January 1994
• Python 1.2 - April 10, 1995
• Python 1.3 - October 12, 1995
• Python 1.4 - October 25, 1996
• Python 1.5 - December 31, 1997
• Python 1.6 - September 5, 2000
• Python 2.0 - October 16, 2000
• Python 2.1 - April 15, 2001
• Python 2.2 - December 21, 2001
• Python 2.3 - July 29, 2003
• Python 2.4 - November 30, 2004
• Python 2.5 - September 19, 2006
• Python 2.6 - October 1, 2008
• Python 2.7 - July 3, 2010
6
Python 3.0 - December 3, 2008
Python 3.1 - June 27, 2009
Python 3.2 - February 20, 2011
Python 3.3 - September 29, 2012
Python 3.4 - March 16, 2014
Python 3.5 - September 13, 2015
Python 3.6 - December 23, 2016
Python 3.7 - June 27, 2018
Python 3.8 - October 19, 2019
Python 3.9 - October 05, 2020
Python 3.10 - October 04, 2021
Python features
• Easy to learn, fast to develop
• The grammar is easy to learn and understand, suitable for beginners,
and can accelerate the learning of other languages.
• Several lines of code can be used to complete complex tasks.
• Cross-platform (cross-operating system)
• Powerful standard library (internal modeling group)
• Python built-in standard function library, providing a wide range of
internal modeling groups, such as: text
7
Life is short, you need Python.
• Python classic third-party package
• Web framework: Django, Flask, Pyramid, web2py
• GUI development: PyQt, Tkinter, wxPython App development: kivy
• Crawler: Scrapy, selenium, beautifulsoup
• Data science: numpy, scipy, matplotlib, pandas Machine learning:
keras, tensorflow
• Python official kit website: Pypi
8
Third-party kit
• Python third-party kit recommendation website
• https://python.libhunt.com/categories?fbclid=IwAR3NRxa8sCBaK-
ndsx6D5fkYbQOny1Ya2qRlpD-Z6cRJZi_0kJ-Ff4xKLZw
• https://awesome-python.com/
9
Programming language popularity ranking
10
Python Programming Basics for Beginners
• Install Anaconda for Windows (Individual Edition)
• https://www.anaconda.com/products/individual
11
Python Programming Basics for Beginners
• print() function
• The print() function in Python is used to print a specified message on the
screen. The print command in Python prints strings or objects which are
converted to a string while printing on a screen.
• print blank lines
• Sometimes you need to print one blank line in your Python program.
Following is an example to perform this task using Python print format.
12
python_exercise_01.ipynb
Python Programming Basics for Beginners
• How to Declare and use a Variable
• Re-declare a Variable
• Python String Concatenation and Variable
• Python Variable Types: Local & Global
• Delete a variable
13
Python Data Structure
• Python TUPLE
• Tuple Matching in Python is a method of grouping the tuples by matching the
second element in the tuples. It is achieved by using a dictionary by checking
the second element in each tuple in python programming. However, we can
make new tuples by taking portions of existing tuples.
• Tuple packing and unpacking.
• Comparing tuples.
• Using tuples as keys in dictionaries.
• Deleting Tuples.
• Slicing of Tuple.
14
Python Data Structure
• Advantages of tuple over list
• Iterating through tuple is faster than with list, since tuples are immutable.
• Tuples that consist of immutable elements can be used as key for dictionary,
which is not possible with list
• If you have data that is immutable, implementing it as tuple will guarantee
that it remains write-protected
15
Python Data Structure
• Try
• To perform different task, tuple allows you to use many built-in functions like
all(), any(), enumerate(), max(), min(), sorted(), len()
16
Python Dictionary
• A Dictionary in Python is the unordered and changeable collection of
data values that holds key-value pairs.
• Each key-value pair in the dictionary maps the key to its associated
value making it more optimized.
• A Dictionary in python is declared by enclosing a comma-separated
list of key-value pairs using curly braces{}.
• Updating Dictionary
• Delete Keys from the dictionary
• Dictionary items() Method
• Sorting the Dictionary
• Merging Dictionaries
17
Python Dictionary
• The ** is called Kwargs in Python, and it will work with Python version
3.5+. Using **
• We can merge two dictionaries, and it will return the merged
dictionary.
18
Python Dictionary
• Dictionary is one of the important data types available in Python. The
data in a dictionary is stored as a key/value pair. It is separated by a
colon(:), and the key/value pair is separated by comma(,).
• Python Dictionary Append
• Accessing elements of a dictionary
• Deleting Element(s) from dictionary using pop() method
• Appending element(s) to a dictionary
• Updating existing element(s) in a dictionary
• Insert a dictionary into another dictionary
19
Python Operators
• Logical Operators in Python are used to perform logical operations on
the values of variables. The value is either true or false. We can figure
out the conditions by the result of the truth values. There are mainly
three types of logical operators in python : logical AND, logical OR and
logical NOT. Operators are represented by keywords or special
characters.
• Arithmetic Operators
• Comparison Operators
• Python Assignment Operators
• Logical Operators or Bitwise Operators
• Membership Operators
• Identity Operators
20
Python Arrays
• A Python Array is a collection of common type of data structures
having elements with same data type. It is used to store collections of
data. In Python programming, an arrays are handled by the “array”
module. If you create arrays using the array module, elements of the
array must be of the same numeric type.
• insert elements
• modify elements
• pop an element from Array
• delete elements
• Search and get the index of a value in an Array
• Reverse an Array
• Traverse an Array
21
Python Arrays
• What is the difference of array and list
• Data type is different
• array: all elements must be all the same type
• list (linked-list): all elements can be multiple data types
22
Python Conditional Loops
• Conditional Statement in Python perform different computations or
actions depending on whether a specific Boolean constraint evaluates
to true or false. Conditional statements are handled by IF statements
in Python.
• Python if Statement
• else condition
• elif condition
• conditional statement with minimal code
• Nested if Statement
• Switch Case Statement
23
Python For & While Loops
• What is Loop?
• Loops can execute a block of code number of times until a certain
condition is met. Their usage is fairly common in programming. Unlike
other programming language that have For Loop, while loop, dowhile, etc.
• What is For Loop?
• For loop is used to iterate over elements of a sequence. It is often used
when you have a piece of code which you want to repeat “n” number of
time.
• What is While Loop?
• While Loop is used to repeat a block of code. Instead of running the code
block once, It executes the code block multiple times until a certain
condition is met.
24
Python break, continue, pass statements
• The break statement takes care of terminating the loop in which it is
used. If the break statement is used inside nested loops, the current
loop is terminated, and the flow will continue with the code followed
that comes after the loop.
• break statement
• break statement inside while-loop
• break Statement inside nested loops
• The continue statement skips the code that comes after it, and the
control is passed back to the start for the next iteration.
• Continue inside for-loop
25
Python break, continue, pass statements
• Python pass statement is used as a placeholder inside loops,
functions, class, if-statement that is meant to be implemented later.
• pass
• pass statement inside the loop
26
Python OOPs
• OOPs in Python is a programming approach that focuses on using
objects and classes as same as other general programming languages.
The objects can be any real-world entities. Python allows developers
to develop applications using the OOPs approach with the major
focus on code reusability. It is very easy to create classes and objects
in Python.
• Inheritance works
• Constructors
27
String
• In Python everything is object and string are an object too. Python string
can be created simply by enclosing characters in the double quote.
• String replace()
• Changing upper and lower case strings
• join function
• Reversing String
• Split Strings
• string format()
• class with format()
• dictionary with format()
• Padding Variable Substitutions
• find() using start and end arguments
28
function
• Python main function is a starting point of any program. When the
program is run, the python interpreter runs the code sequentially.
Main function is executed only when it is run as a Python program. It
will not run the main function if it imported as a module.
• __name__ variable and Python Module
• defile function
29
lambda function
• A Lambda Function in Python programming is an anonymous function
or a function having no name. It is a small and restricted function
having no more than one line. Just like a normal function, a Lambda
function can have multiple arguments with one expression.
• lambdas in filter()
• lambdas in map()
• lambdas in reduce()
• abs(), round(), range(), map()
30
Generators
• Generators are functions that return an iterable generator object.
• The values from the generator object are fetched one at a time
instead of the full list together and hence to get the actual values you
can use a for-loop, using next() or list() method.
• read the values from the generator
31
Queue
• A queue is a container that holds data.
• The data that is entered first will be removed first, and hence a queue
is also called First in First Out (FIFO).
• Add and item in a queue
• Remove an item from the queue
• Last In First Out queue
• Remove an item from the queue
• Add more than 1 item in a queue
• Add and item in a LIFO queue
32
counter, enumerate
• Python Counter takes in input a list, tuple, dictionary, string, which
are all iterable objects, and it will give you output that will have the
count of each element.
• counter()
• enumerate()
• enumerate a dictionary
33
type() and isinstance()
• Python has a built-in function called type() that helps you find the
class type of the variable given as input
34
Homework Assignment
• Use python range function to output nine-nine multiplication table
• Use python output Fibonacci-Series by using generators and yield
function
• Output: Fibonacci-Series: [0,1,1,2,3,5,8]
• Sorting queue
35

More Related Content

What's hot (20)

PDF
Python final ppt
Ripal Ranpara
 
PPTX
Introduction to python for Beginners
Sujith Kumar
 
PPTX
Python Introduction | JNTUA | R19 | UNIT 1
FabMinds
 
PPTX
Type hints in python & mypy
Anirudh
 
PDF
Python Crash Course
Haim Michael
 
PDF
Python for All
Pragya Goyal
 
PPTX
Python presentation
gaganapponix
 
ODP
20120314 changa-python-workshop
amptiny
 
PPTX
Python and its Applications
Abhijeet Singh
 
PPTX
Python Summer Internship
Atul Kumar
 
KEY
Programming with Python: Week 1
Ahmet Bulut
 
PDF
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
EditorIJAERD
 
PDF
summer training report on python
Shubham Yadav
 
PPTX
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 
PDF
Research paper on python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
PPTX
Why Python?
Adam Pah
 
PPTX
Introduction about Python by JanBask Training
JanBask Training
 
PPT
Python Programming ppt
ismailmrribi
 
PDF
Python: the Project, the Language and the Style
Juan-Manuel Gimeno
 
PPT
Python and data analytics
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Python final ppt
Ripal Ranpara
 
Introduction to python for Beginners
Sujith Kumar
 
Python Introduction | JNTUA | R19 | UNIT 1
FabMinds
 
Type hints in python & mypy
Anirudh
 
Python Crash Course
Haim Michael
 
Python for All
Pragya Goyal
 
Python presentation
gaganapponix
 
20120314 changa-python-workshop
amptiny
 
Python and its Applications
Abhijeet Singh
 
Python Summer Internship
Atul Kumar
 
Programming with Python: Week 1
Ahmet Bulut
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
EditorIJAERD
 
summer training report on python
Shubham Yadav
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 
Research paper on python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Why Python?
Adam Pah
 
Introduction about Python by JanBask Training
JanBask Training
 
Python Programming ppt
ismailmrribi
 
Python: the Project, the Language and the Style
Juan-Manuel Gimeno
 

Similar to Python indroduction (20)

PPT
Python - Module 1.ppt
jaba kumar
 
PPTX
cupdf.com_python-seminar-ppt.pptx.........
ansuljoshi8456
 
PPTX
PYTHON INTERNSHIP PPT download free.pptx
dhruvn097
 
PPTX
Introduction to Python Programming Language
merlinjohnsy
 
PDF
python-160403194316.pdf
gmadhu8
 
PPTX
Python Seminar PPT
Shivam Gupta
 
PPTX
Python
Shivam Gupta
 
PPTX
Basic of Python- Hands on Session
Dharmesh Tank
 
PPTX
Python in 30 minutes!
Fariz Darari
 
PDF
Learn Python 3 for absolute beginners
KingsleyAmankwa
 
PPTX
Python Introduction
Punithavel Ramani
 
PDF
Python Module-1.1.pdf
4HG19EC010HARSHITHAH
 
PPTX
python presntation 2.pptx
Arpittripathi45
 
PPTX
Python ppt_118.pptx
MadhuriAnaparthy
 
PDF
Python: An introduction A summer workshop
ForrayFerenc
 
PDF
GE3151_PSPP_UNIT_2_Notes
Guru Nanak Technical Institutions
 
PPTX
Python-The programming Language
Rohan Gupta
 
PPTX
Python_IoT.pptx
SwatiChoudhary95
 
PPTX
unit (1)INTRODUCTION TO PYTHON course.pptx
usvirat1805
 
PDF
Python Programming Note for only beginers
sifatullah42
 
Python - Module 1.ppt
jaba kumar
 
cupdf.com_python-seminar-ppt.pptx.........
ansuljoshi8456
 
PYTHON INTERNSHIP PPT download free.pptx
dhruvn097
 
Introduction to Python Programming Language
merlinjohnsy
 
python-160403194316.pdf
gmadhu8
 
Python Seminar PPT
Shivam Gupta
 
Python
Shivam Gupta
 
Basic of Python- Hands on Session
Dharmesh Tank
 
Python in 30 minutes!
Fariz Darari
 
Learn Python 3 for absolute beginners
KingsleyAmankwa
 
Python Introduction
Punithavel Ramani
 
Python Module-1.1.pdf
4HG19EC010HARSHITHAH
 
python presntation 2.pptx
Arpittripathi45
 
Python ppt_118.pptx
MadhuriAnaparthy
 
Python: An introduction A summer workshop
ForrayFerenc
 
GE3151_PSPP_UNIT_2_Notes
Guru Nanak Technical Institutions
 
Python-The programming Language
Rohan Gupta
 
Python_IoT.pptx
SwatiChoudhary95
 
unit (1)INTRODUCTION TO PYTHON course.pptx
usvirat1805
 
Python Programming Note for only beginers
sifatullah42
 
Ad

More from FEG (20)

PDF
Supervised learning in decision tree algorithm
FEG
 
PDF
Unsupervised learning in data clustering
FEG
 
PDF
CNN_Image Classification for deep learning.pdf
FEG
 
PDF
Sequence Model with practicing hands on coding.pdf
FEG
 
PDF
Seq2seq Model introduction with practicing hands on coding.pdf
FEG
 
PDF
AIGEN introduction with practicing hands on coding.pdf
FEG
 
PDF
資料視覺化_Exploation_Data_Analysis_20241015.pdf
FEG
 
PDF
Operation_research_Linear_programming_20241015.pdf
FEG
 
PDF
Operation_research_Linear_programming_20241112.pdf
FEG
 
PDF
非監督是學習_Kmeans_process_visualization20241110.pdf
FEG
 
PDF
Sequence Model pytorch at colab with gpu.pdf
FEG
 
PDF
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
FEG
 
PDF
資料視覺化_透過Orange3進行_無須寫程式直接使用_碩士學程_202403.pdf
FEG
 
PDF
Pytorch cnn netowork introduction 20240318
FEG
 
PDF
2023 Decision Tree analysis in business practices
FEG
 
PDF
2023 Clustering analysis using Python from scratch
FEG
 
PDF
2023 Data visualization using Python from scratch
FEG
 
PDF
2023 Supervised Learning for Orange3 from scratch
FEG
 
PDF
2023 Supervised_Learning_Association_Rules
FEG
 
PDF
202312 Exploration Data Analysis Visualization (English version)
FEG
 
Supervised learning in decision tree algorithm
FEG
 
Unsupervised learning in data clustering
FEG
 
CNN_Image Classification for deep learning.pdf
FEG
 
Sequence Model with practicing hands on coding.pdf
FEG
 
Seq2seq Model introduction with practicing hands on coding.pdf
FEG
 
AIGEN introduction with practicing hands on coding.pdf
FEG
 
資料視覺化_Exploation_Data_Analysis_20241015.pdf
FEG
 
Operation_research_Linear_programming_20241015.pdf
FEG
 
Operation_research_Linear_programming_20241112.pdf
FEG
 
非監督是學習_Kmeans_process_visualization20241110.pdf
FEG
 
Sequence Model pytorch at colab with gpu.pdf
FEG
 
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
FEG
 
資料視覺化_透過Orange3進行_無須寫程式直接使用_碩士學程_202403.pdf
FEG
 
Pytorch cnn netowork introduction 20240318
FEG
 
2023 Decision Tree analysis in business practices
FEG
 
2023 Clustering analysis using Python from scratch
FEG
 
2023 Data visualization using Python from scratch
FEG
 
2023 Supervised Learning for Orange3 from scratch
FEG
 
2023 Supervised_Learning_Association_Rules
FEG
 
202312 Exploration Data Analysis Visualization (English version)
FEG
 
Ad

Recently uploaded (20)

PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
July Patch Tuesday
Ivanti
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Python basic programing language for automation
DanialHabibi2
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 

Python indroduction

  • 2. About me • Education • NCU (MIS)、NCCU (CS) • Work Experience • Telecom big data Innovation • AI projects • Retail marketing technology • User Group • TW Spark User Group • TW Hadoop User Group • Taiwan Data Engineer Association Director • Research • Big Data/ ML/ AIOT/ AI Columnist 2
  • 3. Tutorial Content 3 Python Programming Basics for Beginners Homework Brief introduction Python basic tutorials
  • 4. Code • Download code • https://github.com/orozcohsu/ntunhs_2021.git • Folder • 20211101_inter_master 4
  • 5. What can Python do? •Console application •Desktop application •Web application •Mobile application •Machine Learning •Data Science •IOT application •And many more … 5
  • 6. Python version • Python 0.9.0 - February 20, 1991 • Python 0.9.1 - 1991 • Python 0.9.2 - 1991 • Python 1.0 - January 1994 • Python 1.2 - April 10, 1995 • Python 1.3 - October 12, 1995 • Python 1.4 - October 25, 1996 • Python 1.5 - December 31, 1997 • Python 1.6 - September 5, 2000 • Python 2.0 - October 16, 2000 • Python 2.1 - April 15, 2001 • Python 2.2 - December 21, 2001 • Python 2.3 - July 29, 2003 • Python 2.4 - November 30, 2004 • Python 2.5 - September 19, 2006 • Python 2.6 - October 1, 2008 • Python 2.7 - July 3, 2010 6 Python 3.0 - December 3, 2008 Python 3.1 - June 27, 2009 Python 3.2 - February 20, 2011 Python 3.3 - September 29, 2012 Python 3.4 - March 16, 2014 Python 3.5 - September 13, 2015 Python 3.6 - December 23, 2016 Python 3.7 - June 27, 2018 Python 3.8 - October 19, 2019 Python 3.9 - October 05, 2020 Python 3.10 - October 04, 2021
  • 7. Python features • Easy to learn, fast to develop • The grammar is easy to learn and understand, suitable for beginners, and can accelerate the learning of other languages. • Several lines of code can be used to complete complex tasks. • Cross-platform (cross-operating system) • Powerful standard library (internal modeling group) • Python built-in standard function library, providing a wide range of internal modeling groups, such as: text 7
  • 8. Life is short, you need Python. • Python classic third-party package • Web framework: Django, Flask, Pyramid, web2py • GUI development: PyQt, Tkinter, wxPython App development: kivy • Crawler: Scrapy, selenium, beautifulsoup • Data science: numpy, scipy, matplotlib, pandas Machine learning: keras, tensorflow • Python official kit website: Pypi 8
  • 9. Third-party kit • Python third-party kit recommendation website • https://python.libhunt.com/categories?fbclid=IwAR3NRxa8sCBaK- ndsx6D5fkYbQOny1Ya2qRlpD-Z6cRJZi_0kJ-Ff4xKLZw • https://awesome-python.com/ 9
  • 11. Python Programming Basics for Beginners • Install Anaconda for Windows (Individual Edition) • https://www.anaconda.com/products/individual 11
  • 12. Python Programming Basics for Beginners • print() function • The print() function in Python is used to print a specified message on the screen. The print command in Python prints strings or objects which are converted to a string while printing on a screen. • print blank lines • Sometimes you need to print one blank line in your Python program. Following is an example to perform this task using Python print format. 12 python_exercise_01.ipynb
  • 13. Python Programming Basics for Beginners • How to Declare and use a Variable • Re-declare a Variable • Python String Concatenation and Variable • Python Variable Types: Local & Global • Delete a variable 13
  • 14. Python Data Structure • Python TUPLE • Tuple Matching in Python is a method of grouping the tuples by matching the second element in the tuples. It is achieved by using a dictionary by checking the second element in each tuple in python programming. However, we can make new tuples by taking portions of existing tuples. • Tuple packing and unpacking. • Comparing tuples. • Using tuples as keys in dictionaries. • Deleting Tuples. • Slicing of Tuple. 14
  • 15. Python Data Structure • Advantages of tuple over list • Iterating through tuple is faster than with list, since tuples are immutable. • Tuples that consist of immutable elements can be used as key for dictionary, which is not possible with list • If you have data that is immutable, implementing it as tuple will guarantee that it remains write-protected 15
  • 16. Python Data Structure • Try • To perform different task, tuple allows you to use many built-in functions like all(), any(), enumerate(), max(), min(), sorted(), len() 16
  • 17. Python Dictionary • A Dictionary in Python is the unordered and changeable collection of data values that holds key-value pairs. • Each key-value pair in the dictionary maps the key to its associated value making it more optimized. • A Dictionary in python is declared by enclosing a comma-separated list of key-value pairs using curly braces{}. • Updating Dictionary • Delete Keys from the dictionary • Dictionary items() Method • Sorting the Dictionary • Merging Dictionaries 17
  • 18. Python Dictionary • The ** is called Kwargs in Python, and it will work with Python version 3.5+. Using ** • We can merge two dictionaries, and it will return the merged dictionary. 18
  • 19. Python Dictionary • Dictionary is one of the important data types available in Python. The data in a dictionary is stored as a key/value pair. It is separated by a colon(:), and the key/value pair is separated by comma(,). • Python Dictionary Append • Accessing elements of a dictionary • Deleting Element(s) from dictionary using pop() method • Appending element(s) to a dictionary • Updating existing element(s) in a dictionary • Insert a dictionary into another dictionary 19
  • 20. Python Operators • Logical Operators in Python are used to perform logical operations on the values of variables. The value is either true or false. We can figure out the conditions by the result of the truth values. There are mainly three types of logical operators in python : logical AND, logical OR and logical NOT. Operators are represented by keywords or special characters. • Arithmetic Operators • Comparison Operators • Python Assignment Operators • Logical Operators or Bitwise Operators • Membership Operators • Identity Operators 20
  • 21. Python Arrays • A Python Array is a collection of common type of data structures having elements with same data type. It is used to store collections of data. In Python programming, an arrays are handled by the “array” module. If you create arrays using the array module, elements of the array must be of the same numeric type. • insert elements • modify elements • pop an element from Array • delete elements • Search and get the index of a value in an Array • Reverse an Array • Traverse an Array 21
  • 22. Python Arrays • What is the difference of array and list • Data type is different • array: all elements must be all the same type • list (linked-list): all elements can be multiple data types 22
  • 23. Python Conditional Loops • Conditional Statement in Python perform different computations or actions depending on whether a specific Boolean constraint evaluates to true or false. Conditional statements are handled by IF statements in Python. • Python if Statement • else condition • elif condition • conditional statement with minimal code • Nested if Statement • Switch Case Statement 23
  • 24. Python For & While Loops • What is Loop? • Loops can execute a block of code number of times until a certain condition is met. Their usage is fairly common in programming. Unlike other programming language that have For Loop, while loop, dowhile, etc. • What is For Loop? • For loop is used to iterate over elements of a sequence. It is often used when you have a piece of code which you want to repeat “n” number of time. • What is While Loop? • While Loop is used to repeat a block of code. Instead of running the code block once, It executes the code block multiple times until a certain condition is met. 24
  • 25. Python break, continue, pass statements • The break statement takes care of terminating the loop in which it is used. If the break statement is used inside nested loops, the current loop is terminated, and the flow will continue with the code followed that comes after the loop. • break statement • break statement inside while-loop • break Statement inside nested loops • The continue statement skips the code that comes after it, and the control is passed back to the start for the next iteration. • Continue inside for-loop 25
  • 26. Python break, continue, pass statements • Python pass statement is used as a placeholder inside loops, functions, class, if-statement that is meant to be implemented later. • pass • pass statement inside the loop 26
  • 27. Python OOPs • OOPs in Python is a programming approach that focuses on using objects and classes as same as other general programming languages. The objects can be any real-world entities. Python allows developers to develop applications using the OOPs approach with the major focus on code reusability. It is very easy to create classes and objects in Python. • Inheritance works • Constructors 27
  • 28. String • In Python everything is object and string are an object too. Python string can be created simply by enclosing characters in the double quote. • String replace() • Changing upper and lower case strings • join function • Reversing String • Split Strings • string format() • class with format() • dictionary with format() • Padding Variable Substitutions • find() using start and end arguments 28
  • 29. function • Python main function is a starting point of any program. When the program is run, the python interpreter runs the code sequentially. Main function is executed only when it is run as a Python program. It will not run the main function if it imported as a module. • __name__ variable and Python Module • defile function 29
  • 30. lambda function • A Lambda Function in Python programming is an anonymous function or a function having no name. It is a small and restricted function having no more than one line. Just like a normal function, a Lambda function can have multiple arguments with one expression. • lambdas in filter() • lambdas in map() • lambdas in reduce() • abs(), round(), range(), map() 30
  • 31. Generators • Generators are functions that return an iterable generator object. • The values from the generator object are fetched one at a time instead of the full list together and hence to get the actual values you can use a for-loop, using next() or list() method. • read the values from the generator 31
  • 32. Queue • A queue is a container that holds data. • The data that is entered first will be removed first, and hence a queue is also called First in First Out (FIFO). • Add and item in a queue • Remove an item from the queue • Last In First Out queue • Remove an item from the queue • Add more than 1 item in a queue • Add and item in a LIFO queue 32
  • 33. counter, enumerate • Python Counter takes in input a list, tuple, dictionary, string, which are all iterable objects, and it will give you output that will have the count of each element. • counter() • enumerate() • enumerate a dictionary 33
  • 34. type() and isinstance() • Python has a built-in function called type() that helps you find the class type of the variable given as input 34
  • 35. Homework Assignment • Use python range function to output nine-nine multiplication table • Use python output Fibonacci-Series by using generators and yield function • Output: Fibonacci-Series: [0,1,1,2,3,5,8] • Sorting queue 35