SlideShare a Scribd company logo
1 of 20
Download to read offline
INTRODUCTION TO PYTHON 3
Sakis Kasampalis
Full-Stack Developer
Pycom
@SKasampalis
sakisk.me
My Python background (1/2)
> R&D Software Engineer (2011)
> python-patterns (2012)
> Technical Reviewer (2013)
My Python background (2/2)
> Technical Reviewer (2014)
> Author (2015)
> Full-Stack developer (2016)
What is Python?
> General purpose (not just scripting!)
> Multiplatform (GNU/Linux, Windows,
macOS, microcontrollers, …)
> Multiparadigm (procedural, OOP,
functional)
> Focuses on readability and getting
things done
> Batteries included (SQLite, JSON, e-
mail, …)
Let’s start exploring
> Go to python.org (REPL introduction)
> Dynamically (but strongly) typed
> Just 3 data types (int, float, str)
> Install PyCharm (jetbrains.com)
> Play with user input
bit.ly/python-tmc
Lists
> Generic (any datatype)
> Mutable (append vs extend vs insert)
> Stack compatible (append, pop)
> Ordered
Tuples
> Generic (any datatype)
> Immutable
> Faster (and safer) than lists
> Ordered
Sets
> Generic (any datatype)
> Mutable
> Unordered
> Unique items
> All common set operations supported
(union, intersection, difference, …)
Dictionaries
> Generic (any datatype)
> Mutable
> Unordered
> Key-Value pairs
> Fast lookup
Uniform operations - Existence
> Check if an element exists
> Use the in keyword
> Works on all structures (also strings)
Uniform operations - Counting
> Get the number of elements
> Use the len function
> Works on all structures (also strings)
Semi-uniform operations - Indexing
> Access individual elements
> Works on all ordered structures (also
strings)
> For dicts use the keys function
> For sets use the in keyword
Semi-uniform operations - Slicing
> Access multiple sequential elements
> Works on all ordered structures (also
strings)
+---+---+---+---+---+---+
| P | y | t | h | o | n |
+---+---+---+---+---+---+
0 1 2 3 4 5 6
-6 -5 -4 -3 -2 -1
> Syntax [start:end:step]
> Default: start = 0, step = 1
Semi-uniform operations - Deleting
> Remove a specific element
> Use the del operator
> Works on all mutable structures but sets
(beware: strings are immutable)
> For sets use the remove function
> For strings use slicing
A last uniform operation - Comprehensions
> Write more compact code
> Apply an expression on all elements
> Works on all structures (also strings)
> [expr for … for … if …]
> Readability matters (use responsibly)
I/O and files
> Introduction to str.format
> Be explicit about the mode and
encoding
> Use the with statement when possible
Exception handling
> Use the try-except-else idiom
> Exception hierarchy list
> Explore try-except
Object Oriented Programming (OOP)
> self is a convention (but please use it)
> No encapsulation (we are all adults)
> A different OOP notion
> Polymorphism using duck typing
Your turn
> Download and print the number of
items
> Install beautiful soup version 4 (bs4)
> Help: beatiful soup documentation
> Find some content that you want to download
(e.g. xkcd “Python”, flickr “sunset”)
> My example: bit.ly/flickrfetch
References
> docs.python.org
> Mark Pilgrim, Dive Into Python 3
(diveintopython3.net)
> pythonprogramminglanguage.com
> Steven F. Lott, Mastering Object-
Oriented Python
> Al Sweigart, Automate the boring stuff
with Python (automatetheboringstuff.com)

More Related Content

What's hot (20)

PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Python programming
Python programmingPython programming
Python programming
 
Python for Security Professionals
Python for Security ProfessionalsPython for Security Professionals
Python for Security Professionals
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
Java I/O
Java I/OJava I/O
Java I/O
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for Bioinformatics
 
Python programming
Python programmingPython programming
Python programming
 
Linux Internals - Part III
Linux Internals - Part IIILinux Internals - Part III
Linux Internals - Part III
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Posix Threads
Posix ThreadsPosix Threads
Posix Threads
 
Python Session - 2
Python Session - 2Python Session - 2
Python Session - 2
 
Demystifying how imports work in Python
Demystifying how imports work in PythonDemystifying how imports work in Python
Demystifying how imports work in Python
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
 
Java threads
Java threadsJava threads
Java threads
 
Threads in java
Threads in javaThreads in java
Threads in java
 
Why Python (for Statisticians)
Why Python (for Statisticians)Why Python (for Statisticians)
Why Python (for Statisticians)
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
 
Python
PythonPython
Python
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way Presentation
 

Similar to Introduction to Python 3

01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.pptVicVic56
 
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...admin369652
 
unit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptxunit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptxusvirat1805
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
Python Workshop. LUG Maniapl
Python Workshop. LUG ManiaplPython Workshop. LUG Maniapl
Python Workshop. LUG ManiaplAnkur Shrivastava
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introductioncaswenson
 
Introduction to Python3 Programming Language
Introduction to Python3 Programming LanguageIntroduction to Python3 Programming Language
Introduction to Python3 Programming LanguageTushar Mittal
 
Python lab basics
Python lab basicsPython lab basics
Python lab basicsAbi_Kasi
 
Beyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureBeyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureJayaram Sankaranarayanan
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administrationvceder
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txvishwanathgoudapatil1
 

Similar to Introduction to Python 3 (20)

01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.ppt
 
Erlang
ErlangErlang
Erlang
 
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
 
Elm kyivfprog 2015
Elm kyivfprog 2015Elm kyivfprog 2015
Elm kyivfprog 2015
 
Python Programming Basics
Python Programming BasicsPython Programming Basics
Python Programming Basics
 
unit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptxunit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptx
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
Python Workshop. LUG Maniapl
Python Workshop. LUG ManiaplPython Workshop. LUG Maniapl
Python Workshop. LUG Maniapl
 
Python Orientation
Python OrientationPython Orientation
Python Orientation
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
Pythonintroduction
PythonintroductionPythonintroduction
Pythonintroduction
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
 
Introduction to Python3 Programming Language
Introduction to Python3 Programming LanguageIntroduction to Python3 Programming Language
Introduction to Python3 Programming Language
 
Python lab basics
Python lab basicsPython lab basics
Python lab basics
 
Python for dummies
Python for dummiesPython for dummies
Python for dummies
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Beyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureBeyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software Architecture
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
 
Advance python
Advance pythonAdvance python
Advance python
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

Introduction to Python 3

  • 1. INTRODUCTION TO PYTHON 3 Sakis Kasampalis Full-Stack Developer Pycom @SKasampalis sakisk.me
  • 2. My Python background (1/2) > R&D Software Engineer (2011) > python-patterns (2012) > Technical Reviewer (2013)
  • 3. My Python background (2/2) > Technical Reviewer (2014) > Author (2015) > Full-Stack developer (2016)
  • 4. What is Python? > General purpose (not just scripting!) > Multiplatform (GNU/Linux, Windows, macOS, microcontrollers, …) > Multiparadigm (procedural, OOP, functional) > Focuses on readability and getting things done > Batteries included (SQLite, JSON, e- mail, …)
  • 5. Let’s start exploring > Go to python.org (REPL introduction) > Dynamically (but strongly) typed > Just 3 data types (int, float, str) > Install PyCharm (jetbrains.com) > Play with user input bit.ly/python-tmc
  • 6. Lists > Generic (any datatype) > Mutable (append vs extend vs insert) > Stack compatible (append, pop) > Ordered
  • 7. Tuples > Generic (any datatype) > Immutable > Faster (and safer) than lists > Ordered
  • 8. Sets > Generic (any datatype) > Mutable > Unordered > Unique items > All common set operations supported (union, intersection, difference, …)
  • 9. Dictionaries > Generic (any datatype) > Mutable > Unordered > Key-Value pairs > Fast lookup
  • 10. Uniform operations - Existence > Check if an element exists > Use the in keyword > Works on all structures (also strings)
  • 11. Uniform operations - Counting > Get the number of elements > Use the len function > Works on all structures (also strings)
  • 12. Semi-uniform operations - Indexing > Access individual elements > Works on all ordered structures (also strings) > For dicts use the keys function > For sets use the in keyword
  • 13. Semi-uniform operations - Slicing > Access multiple sequential elements > Works on all ordered structures (also strings) +---+---+---+---+---+---+ | P | y | t | h | o | n | +---+---+---+---+---+---+ 0 1 2 3 4 5 6 -6 -5 -4 -3 -2 -1 > Syntax [start:end:step] > Default: start = 0, step = 1
  • 14. Semi-uniform operations - Deleting > Remove a specific element > Use the del operator > Works on all mutable structures but sets (beware: strings are immutable) > For sets use the remove function > For strings use slicing
  • 15. A last uniform operation - Comprehensions > Write more compact code > Apply an expression on all elements > Works on all structures (also strings) > [expr for … for … if …] > Readability matters (use responsibly)
  • 16. I/O and files > Introduction to str.format > Be explicit about the mode and encoding > Use the with statement when possible
  • 17. Exception handling > Use the try-except-else idiom > Exception hierarchy list > Explore try-except
  • 18. Object Oriented Programming (OOP) > self is a convention (but please use it) > No encapsulation (we are all adults) > A different OOP notion > Polymorphism using duck typing
  • 19. Your turn > Download and print the number of items > Install beautiful soup version 4 (bs4) > Help: beatiful soup documentation > Find some content that you want to download (e.g. xkcd “Python”, flickr “sunset”) > My example: bit.ly/flickrfetch
  • 20. References > docs.python.org > Mark Pilgrim, Dive Into Python 3 (diveintopython3.net) > pythonprogramminglanguage.com > Steven F. Lott, Mastering Object- Oriented Python > Al Sweigart, Automate the boring stuff with Python (automatetheboringstuff.com)