SlideShare a Scribd company logo
1 of 42
IntroducingIntroducing
2
Agenda
What is Python?
Features
Characteristics
Programming in Python
Modules and Tools
Q&A
3
What is Python?
Created by Guido Van Rossum as a successor
to the ABC programming language
Conceived in 1980, started development in
1989, v1.0 out in 1994
Name is derived from Monty Python’s Flying
Circus
4
Python in the real world
Uses millions of lines of Python code for ad
management to build automation
Employs the creator of Python himself
5
Python in the real world
Industrial Light & Magic
Uses Python to automate visual effects
6
Python in the real world
Uses Python for their desktop application
Python automates the synchronization and file
sending over the internet to Dropbox’s cloud
storage servers
7
Python in the real world
Django web framework is built using Python
Notable users of Django are some of the
biggest websites today
8
Python in the real world
Blender, a 3D Imaging program uses Python
as its main scripting language
9
Python in the real world
Minecraft uses Python as its scripting language
to automate building
10
Python in the real world
Google
Industrial Light and Magic (Star Wars)
Django web framework (used in Pinterest, Instagram, Mozilla)
Dropbox
Reddit
LibreOffice
Games (Battlefield, EVE Online, Civilization IV, Minecraft, etc.)
...and many more!
11
Why Python?
Simple, like speaking English
It’s FOSS! Lots of resources available
High level programming language
Object-oriented, but not enforced
Portable, works on a lot of different systems
Can be embedded in programs for scripting capabilities
Extensive libraries available
Extensible
12
Getting Started
Go to https://www.python.org and download
the latest version of Python for your OS
13
Installing on Windows
Add Python 3.5 to PATH
14
Running Python
Run the Python interpreter by typing “python”
in the command line
15
Basic Characteristics
Organized syntax
Indentation is strictly enforced
Encourages proper programming practices
Dynamic variable typing
Variables are simply names that refer to objects
No defined data type during compile time
16
Simple and Readable
Python programs look like pseudo-code
compared to other prominent languages
Sample code – helloworld.py
17
Indentation
Proper Indentation is enforced to identify
sections within your program (functions,
procedures, classes)
Sample code – guessgame.py
18
Indentation
19
Built-in Data Types
Boolean
Numbers (integers, real, complex)
Strings
Sequence Types
Tuples
Lists (resize-able arrays)
Range
Set Types
Set, FrozenSet
Dictionary
20
Data Types – Tuples
class tuple([iterable])
Immutable sequence of data – once assigned,
elements within cannot be changed
Using a pair of parentheses to denote the empty tuple:
()
Using a trailing comma for a singleton tuple: a, or (a,)
Separating items with commas: a, b, c or (a, b, c)
Using the tuple() built-in: tuple() or tuple(iterable)
21
Data Types – Tuples
Sample code:
Output:
22
Data Types – Tuples
Python Expression Result Description
Len((1,2,3)) 3 Length
(1,2,3) + (4,5,6) (1,2,3,4,5,6) Concatenation
('Hi!',) * 4 ('Hi!', 'Hi!', 'Hi!', 'Hi!') Repetition
3 in (1, 2, 3) True Membership
for x in (1, 2, 3):
print(x)
1 2 3 Iteration
Basic tuple operations
23
Data Types – List
class list([iterable])
Mutable sequence of data – once assigned,
elements within cannot be changed
Using a pair of square brackets to denote the empty
list: []
Using square brackets, separating items with commas:
[a], [a, b, c]
Using a list comprehension: [x for x in iterable]
Using the type constructor: list() or list(iterable)
24
Data Types – List
Sample code:
Output:
25
Data Types – List
Basic list operations
Python Expression Result Description
Len([1,2,3]) 3 Length
[1,2,3] + [4,5,6] [1,2,3,4,5,6] Concatenation
['Hi!',] * 4 ['Hi!', 'Hi!', 'Hi!', 'Hi!'] Repetition
3 in [1, 2, 3] True Membership
for x in [1, 2, 3]:
print(x)
1 2 3 Iteration
26
Built-in Functions
Some built-in functions that work with tuples
and lists
min() - Return the smallest item
max() - Return the largest item
len() - Return the length of the object
sorted() - Sorts an iterable object
27
When to use Tuple and List
A tuple’s contents cannot be changed
individually once assigned
Each element of a list can be dynamically
assigned
28
Data Types – Range
class range(stop)
class range(start, stop[, step])
Represents an immutable sequence of numbers and is commonly
used for looping a specific number of times
start - The value of the start parameter (or 0 if the parameter was not
supplied)
stop - The value of the stop parameter
step - The value of the step parameter (or 1 if the parameter was not
supplied)
It only stores the start, stop and step values, calculating
individual items and subranges as needed
29
Data Types – Range
Sample code and output:
30
Data Types – Set
class set([iterable])
class frozenset([iterable])
An unordered collection of distinct hashable
(non-dynamic) objects
Common use includes membership testing,
removing duplicates from a sequence,
mathematical operations (union, intersection,
difference, symmetric difference)
31
Data Types – Set
Sample code and output:
32
Data Types – Dictionary
class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
Immutable sequence of data – once assigned,
elements within cannot be changed
Can be created by placing a comma-separated list of
key: value pairs within braces
Example: {'apple': 10, 'orange': 12} or {10: 'apple', 12:
'orange'}, or by the dict() constructor
33
Data Types – Dictionary
Sample code:
Output:
34
Defining Functions
You can define functions to provide the required functionality. Here are
simple rules to define a function in Python.
Function blocks begin with the keyword def followed by the function name and
parentheses ( ( ) ).
Any input parameters or arguments should be placed within these parentheses.
You can also define parameters inside these parentheses.
The first statement of a function can be an optional statement - the
documentation string of the function or docstring.
The code block within every function starts with a colon (:) and is indented.
The statement return [expression] exits a function. A return statement with no
arguments is the same as return None.
35
Defining Functions
Sample Code and Output:
36
Object-oriented Programming
Object: A unique instance of a data structure that's defined by its class. An
object comprises both data members (class variables and instance
variables) and methods.
Class: A user-defined prototype for an object that defines a set of attributes
that characterize any object of the class. The attributes are data members
(class variables and instance variables) and methods, accessed via dot
notation.
Class variable: A variable that is shared by all instances of a class. Class
variables are defined within a class but outside any of the class's methods.
Class variables are not used as frequently as instance variables are.
Data member: A class variable or instance variable that holds data
associated with a class and its objects.
37
Object-oriented Programming
Instance variable: A variable that is defined inside a method and
belongs only to the current instance of a class.
Inheritance: The transfer of the characteristics of a class to other
classes that are derived from it.
Instance: An individual object of a certain class. An object obj that
belongs to a class Circle, for example, is an instance of the class
Circle.
Instantiation: The creation of an instance of a class.
Method : A special kind of function that is defined in a class
definition.
38
Object-oriented Programming
In this example, we can see a basic
demonstration of using Classes and
Object-Oriented programming
Class → Employee
Class variable → empCount
Data member → name, salary
Instance → emp1 and emp2
Inhertiance → emp1 and emp2
inherits the properties of the class
Employee
Method → displayCount(),
displayEmployee()
39
Commonly Used Standard
Modules
time – provides objects and functions for working with Time
calendar - provides objects and functions for working with Dates
os, shutil – contains functions that allow Python to interact with the operating
system and the shell
sys – common utility scripts needed to process command line arguments
re – regular expression tools for advanced string processing
math – gives access to floating point Mathematical functions and operations
urllib – access internet and processing internet protocols
Smtplib – sending email
40
Graphical Interfaces
41
Notable Third-party Modules
42
Tools

More Related Content

What's hot

What's hot (20)

PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYAPYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
 
The Arrow Library in Kotlin
The Arrow Library in KotlinThe Arrow Library in Kotlin
The Arrow Library in Kotlin
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Scala 3 Is Coming: Martin Odersky Shares What To Know
Scala 3 Is Coming: Martin Odersky Shares What To KnowScala 3 Is Coming: Martin Odersky Shares What To Know
Scala 3 Is Coming: Martin Odersky Shares What To Know
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
 
Python basics
Python basicsPython basics
Python basics
 
LectureNotes-06-DSA
LectureNotes-06-DSALectureNotes-06-DSA
LectureNotes-06-DSA
 
Spsl vi unit final
Spsl vi unit finalSpsl vi unit final
Spsl vi unit final
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
O caml2014 leroy-slides
O caml2014 leroy-slidesO caml2014 leroy-slides
O caml2014 leroy-slides
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
 
Clojure basics
Clojure basicsClojure basics
Clojure basics
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
 
Python numbers
Python numbersPython numbers
Python numbers
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Programming with Python - Week 2
Programming with Python - Week 2Programming with Python - Week 2
Programming with Python - Week 2
 

Viewers also liked

Viewers also liked (16)

Python Hype June
Python Hype JunePython Hype June
Python Hype June
 
Data analysis with pandas
Data analysis with pandasData analysis with pandas
Data analysis with pandas
 
Python Hype?
Python Hype?Python Hype?
Python Hype?
 
Public Outreach - Running an effective campaign
 Public Outreach - Running an effective campaign  Public Outreach - Running an effective campaign
Public Outreach - Running an effective campaign
 
Hello World! with Python
Hello World! with PythonHello World! with Python
Hello World! with Python
 
Pydata-Python tools for webscraping
Pydata-Python tools for webscrapingPydata-Python tools for webscraping
Pydata-Python tools for webscraping
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Wellcome to python
Wellcome to pythonWellcome to python
Wellcome to python
 
Bringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirusBringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirus
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Building an EmPyre with Python
Building an EmPyre with PythonBuilding an EmPyre with Python
Building an EmPyre with Python
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask Training
 
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
A Collaborative Approach to Teach Software Architecture - SIGCSE 2017
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
 
Python and Data Evangelism
Python and Data EvangelismPython and Data Evangelism
Python and Data Evangelism
 
Web scraping com python
Web scraping com pythonWeb scraping com python
Web scraping com python
 

Similar to James Jesus Bermas on Crash Course on Python

CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
faithxdunce63732
 
Introduction to python & its applications.ppt
Introduction to python & its applications.pptIntroduction to python & its applications.ppt
Introduction to python & its applications.ppt
PradeepNB2
 
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
usvirat1805
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Tech
ssuser2678ab
 

Similar to James Jesus Bermas on Crash Course on Python (20)

Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
pythonlibrariesandmodules-210530042906.docx
pythonlibrariesandmodules-210530042906.docxpythonlibrariesandmodules-210530042906.docx
pythonlibrariesandmodules-210530042906.docx
 
Introduction to python & its applications.ppt
Introduction to python & its applications.pptIntroduction to python & its applications.ppt
Introduction to python & its applications.ppt
 
Python for dummies
Python for dummiesPython for dummies
Python for dummies
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdf
 
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
 
AI_2nd Lab.pptx
AI_2nd Lab.pptxAI_2nd Lab.pptx
AI_2nd Lab.pptx
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Tech
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
 
C463_02_python.ppt
C463_02_python.pptC463_02_python.ppt
C463_02_python.ppt
 
C463_02_python.ppt
C463_02_python.pptC463_02_python.ppt
C463_02_python.ppt
 
C463_02_python.ppt
C463_02_python.pptC463_02_python.ppt
C463_02_python.ppt
 
kapil presentation.ppt
kapil presentation.pptkapil presentation.ppt
kapil presentation.ppt
 
Top Python Online Training Institutes in Bangalore
Top Python Online Training Institutes in BangaloreTop Python Online Training Institutes in Bangalore
Top Python Online Training Institutes in Bangalore
 
Python for beginners
Python for beginnersPython for beginners
Python for beginners
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 

More from CP-Union

Foss and ict for the people
Foss and ict for the peopleFoss and ict for the people
Foss and ict for the people
CP-Union
 

More from CP-Union (11)

Albert Gavino on FOSS in Data Science and Analysis
Albert Gavino on FOSS in Data Science and AnalysisAlbert Gavino on FOSS in Data Science and Analysis
Albert Gavino on FOSS in Data Science and Analysis
 
Tito Mari Escaño on The Better Alternative Development and Startup Platform; ...
Tito Mari Escaño on The Better Alternative Development and Startup Platform; ...Tito Mari Escaño on The Better Alternative Development and Startup Platform; ...
Tito Mari Escaño on The Better Alternative Development and Startup Platform; ...
 
Jojit Ballesteros on Introduction to Wikimedia
Jojit Ballesteros on Introduction to WikimediaJojit Ballesteros on Introduction to Wikimedia
Jojit Ballesteros on Introduction to Wikimedia
 
Gerald Villorente on Intro to Docker
Gerald Villorente on Intro to DockerGerald Villorente on Intro to Docker
Gerald Villorente on Intro to Docker
 
Eladio Abquina on FOSS TOOL for Mining Big Data;OCC PORTAL Dashboard Story
Eladio Abquina on FOSS TOOL for Mining Big Data;OCC PORTAL Dashboard StoryEladio Abquina on FOSS TOOL for Mining Big Data;OCC PORTAL Dashboard Story
Eladio Abquina on FOSS TOOL for Mining Big Data;OCC PORTAL Dashboard Story
 
Rep. Carlos Zarate on FOSS and FOI Bill: Status and Ways Forward
Rep. Carlos Zarate on FOSS and FOI Bill: Status and Ways ForwardRep. Carlos Zarate on FOSS and FOI Bill: Status and Ways Forward
Rep. Carlos Zarate on FOSS and FOI Bill: Status and Ways Forward
 
Renan Mara on What is FOSS and SFD.
Renan Mara on What is FOSS and SFD.Renan Mara on What is FOSS and SFD.
Renan Mara on What is FOSS and SFD.
 
Almondz Almodal on Change We Need: FOSS, Better Internet, Data Privacy, atbp.
Almondz Almodal on Change We Need: FOSS, Better Internet, Data Privacy, atbp.Almondz Almodal on Change We Need: FOSS, Better Internet, Data Privacy, atbp.
Almondz Almodal on Change We Need: FOSS, Better Internet, Data Privacy, atbp.
 
On the cybercrime act
On the cybercrime actOn the cybercrime act
On the cybercrime act
 
Foss and ict for the people
Foss and ict for the peopleFoss and ict for the people
Foss and ict for the people
 
Drupal for Non-Profits
Drupal for Non-ProfitsDrupal for Non-Profits
Drupal for Non-Profits
 

Recently uploaded

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 

James Jesus Bermas on Crash Course on Python

  • 3. 3 What is Python? Created by Guido Van Rossum as a successor to the ABC programming language Conceived in 1980, started development in 1989, v1.0 out in 1994 Name is derived from Monty Python’s Flying Circus
  • 4. 4 Python in the real world Uses millions of lines of Python code for ad management to build automation Employs the creator of Python himself
  • 5. 5 Python in the real world Industrial Light & Magic Uses Python to automate visual effects
  • 6. 6 Python in the real world Uses Python for their desktop application Python automates the synchronization and file sending over the internet to Dropbox’s cloud storage servers
  • 7. 7 Python in the real world Django web framework is built using Python Notable users of Django are some of the biggest websites today
  • 8. 8 Python in the real world Blender, a 3D Imaging program uses Python as its main scripting language
  • 9. 9 Python in the real world Minecraft uses Python as its scripting language to automate building
  • 10. 10 Python in the real world Google Industrial Light and Magic (Star Wars) Django web framework (used in Pinterest, Instagram, Mozilla) Dropbox Reddit LibreOffice Games (Battlefield, EVE Online, Civilization IV, Minecraft, etc.) ...and many more!
  • 11. 11 Why Python? Simple, like speaking English It’s FOSS! Lots of resources available High level programming language Object-oriented, but not enforced Portable, works on a lot of different systems Can be embedded in programs for scripting capabilities Extensive libraries available Extensible
  • 12. 12 Getting Started Go to https://www.python.org and download the latest version of Python for your OS
  • 13. 13 Installing on Windows Add Python 3.5 to PATH
  • 14. 14 Running Python Run the Python interpreter by typing “python” in the command line
  • 15. 15 Basic Characteristics Organized syntax Indentation is strictly enforced Encourages proper programming practices Dynamic variable typing Variables are simply names that refer to objects No defined data type during compile time
  • 16. 16 Simple and Readable Python programs look like pseudo-code compared to other prominent languages Sample code – helloworld.py
  • 17. 17 Indentation Proper Indentation is enforced to identify sections within your program (functions, procedures, classes) Sample code – guessgame.py
  • 19. 19 Built-in Data Types Boolean Numbers (integers, real, complex) Strings Sequence Types Tuples Lists (resize-able arrays) Range Set Types Set, FrozenSet Dictionary
  • 20. 20 Data Types – Tuples class tuple([iterable]) Immutable sequence of data – once assigned, elements within cannot be changed Using a pair of parentheses to denote the empty tuple: () Using a trailing comma for a singleton tuple: a, or (a,) Separating items with commas: a, b, c or (a, b, c) Using the tuple() built-in: tuple() or tuple(iterable)
  • 21. 21 Data Types – Tuples Sample code: Output:
  • 22. 22 Data Types – Tuples Python Expression Result Description Len((1,2,3)) 3 Length (1,2,3) + (4,5,6) (1,2,3,4,5,6) Concatenation ('Hi!',) * 4 ('Hi!', 'Hi!', 'Hi!', 'Hi!') Repetition 3 in (1, 2, 3) True Membership for x in (1, 2, 3): print(x) 1 2 3 Iteration Basic tuple operations
  • 23. 23 Data Types – List class list([iterable]) Mutable sequence of data – once assigned, elements within cannot be changed Using a pair of square brackets to denote the empty list: [] Using square brackets, separating items with commas: [a], [a, b, c] Using a list comprehension: [x for x in iterable] Using the type constructor: list() or list(iterable)
  • 24. 24 Data Types – List Sample code: Output:
  • 25. 25 Data Types – List Basic list operations Python Expression Result Description Len([1,2,3]) 3 Length [1,2,3] + [4,5,6] [1,2,3,4,5,6] Concatenation ['Hi!',] * 4 ['Hi!', 'Hi!', 'Hi!', 'Hi!'] Repetition 3 in [1, 2, 3] True Membership for x in [1, 2, 3]: print(x) 1 2 3 Iteration
  • 26. 26 Built-in Functions Some built-in functions that work with tuples and lists min() - Return the smallest item max() - Return the largest item len() - Return the length of the object sorted() - Sorts an iterable object
  • 27. 27 When to use Tuple and List A tuple’s contents cannot be changed individually once assigned Each element of a list can be dynamically assigned
  • 28. 28 Data Types – Range class range(stop) class range(start, stop[, step]) Represents an immutable sequence of numbers and is commonly used for looping a specific number of times start - The value of the start parameter (or 0 if the parameter was not supplied) stop - The value of the stop parameter step - The value of the step parameter (or 1 if the parameter was not supplied) It only stores the start, stop and step values, calculating individual items and subranges as needed
  • 29. 29 Data Types – Range Sample code and output:
  • 30. 30 Data Types – Set class set([iterable]) class frozenset([iterable]) An unordered collection of distinct hashable (non-dynamic) objects Common use includes membership testing, removing duplicates from a sequence, mathematical operations (union, intersection, difference, symmetric difference)
  • 31. 31 Data Types – Set Sample code and output:
  • 32. 32 Data Types – Dictionary class dict(**kwarg) class dict(mapping, **kwarg) class dict(iterable, **kwarg) Immutable sequence of data – once assigned, elements within cannot be changed Can be created by placing a comma-separated list of key: value pairs within braces Example: {'apple': 10, 'orange': 12} or {10: 'apple', 12: 'orange'}, or by the dict() constructor
  • 33. 33 Data Types – Dictionary Sample code: Output:
  • 34. 34 Defining Functions You can define functions to provide the required functionality. Here are simple rules to define a function in Python. Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ). Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses. The first statement of a function can be an optional statement - the documentation string of the function or docstring. The code block within every function starts with a colon (:) and is indented. The statement return [expression] exits a function. A return statement with no arguments is the same as return None.
  • 36. 36 Object-oriented Programming Object: A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods. Class: A user-defined prototype for an object that defines a set of attributes that characterize any object of the class. The attributes are data members (class variables and instance variables) and methods, accessed via dot notation. Class variable: A variable that is shared by all instances of a class. Class variables are defined within a class but outside any of the class's methods. Class variables are not used as frequently as instance variables are. Data member: A class variable or instance variable that holds data associated with a class and its objects.
  • 37. 37 Object-oriented Programming Instance variable: A variable that is defined inside a method and belongs only to the current instance of a class. Inheritance: The transfer of the characteristics of a class to other classes that are derived from it. Instance: An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle. Instantiation: The creation of an instance of a class. Method : A special kind of function that is defined in a class definition.
  • 38. 38 Object-oriented Programming In this example, we can see a basic demonstration of using Classes and Object-Oriented programming Class → Employee Class variable → empCount Data member → name, salary Instance → emp1 and emp2 Inhertiance → emp1 and emp2 inherits the properties of the class Employee Method → displayCount(), displayEmployee()
  • 39. 39 Commonly Used Standard Modules time – provides objects and functions for working with Time calendar - provides objects and functions for working with Dates os, shutil – contains functions that allow Python to interact with the operating system and the shell sys – common utility scripts needed to process command line arguments re – regular expression tools for advanced string processing math – gives access to floating point Mathematical functions and operations urllib – access internet and processing internet protocols Smtplib – sending email

Editor's Notes

  1. Let's agree of what it means, or at least convey a general consensus