SlideShare a Scribd company logo
1 of 12
Python Basics
Outline
• What is Python
• History
• Python Interpreter
• Syntax and Semantics
• Control Structures
• basic types: numbers, strings • container types: lists, dictionaries,
tuples • variables • control structures • functions & procedures •
classes & instances • modules & packages • exceptions • files &
standard library
• Applications
Python
• Simple
• Python is a simple and minimalistic language in nature
• Reading a good python program should be like reading English
• Its Pseudo-code nature allows one to concentrate on the problem rather than the language
• Easy to Learn
• Free & Open source
• Freely distributed and Open source
• Maintained by the Python community
• High Level Language –memory management
• Portable – *runs on anything c code will
Python
• Interpreted
• You run the program straight from the source code.
• Python program Bytecode a platforms native language
• You can just copy over your code to another system and it will auto-magically work! *with python
platform
• Object-Oriented
• Simple and additionally supports procedural programming
• Extensible – easily import other code
• Embeddable –easily place your code in non-python programs
• Extensive libraries
• (i.e. reg. expressions, doc generation, CGI, ftp, web browsers, ZIP, WAV, cryptography, etc...)
(wxPython, Twisted, Python Imaging library)
A Bit of History
• Python was conceived in the late 1980s.
• Guido van Rossum, Benevolent Dictator For Life
• Rossum is Dutch, born in Netherlands, Christmas break bored, big fan of
Monty python’s Flying Circus
• Descendant of ABC programming language, he wrote glob() func in UNIX
• Python 0.9.0 (initial version) was published in 1991
• Python 1.0 was released in 1994: included high-order functions
(lambda, map, filter, and reduce.
• Computer Programming for Everybody (CP4E) initiative
• Launched by Rossum to make programming accessible to more people, with
basic “literacy” similar to those required for English and math skills for some
jobs.
• Python 2.2 was released in 2001: Included unification of types and
classes into one hierarchy, making pythons object model purely
Object-oriented
Python Interpreter
• Interactive interface to Python
% python Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
• Python interpreter evaluates inputs:
>>> 3*(7+2) 27
• Python prompts with ‘>>>’.
• To exit Python: CTRL-D
• Running on UNIX
% python filename.py
• You could make the *.py file executable and add: #!/usr/bin/env python to the
top to make it runnable.
Syntax and Semantics
Data and Container Types
Control Structures
Loops/Iterations
• sentence = ['Marry','had','a','little','lamb’]
• for word in sentence:
print word, len(word)
• for i in range(10):
print i
for i in xrange(1000): # does not allocate all initially
print i
• while True:
pass
• for i in xrange(10):
if i == 3: continue
if i == 5: break
print i,
Functions
• def print_hello():# returns nothing
print “hello”
• def has_args(arg1,arg2=['e', 0]):
num = arg1 + 4
mylist = arg2 + ['a',7]
return [num, mylist]
has_args(5.16,[1,'b'])# returns [9.16,[[1, ‘b’],[ ‘a’,7]]
• def duplicate_n_maker(n): #lambda on the fly func.
return lambda arg1:arg1*n
dup3 = duplicate_n_maker(3)
dup_str = dup3('go') # dup_str == 'gogogo'
python.pptx

More Related Content

Similar to python.pptx

Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.pptRehnawilson1
 
Python Programming
Python ProgrammingPython Programming
Python ProgrammingRenieMathews
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptxArpittripathi45
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unitmichaelaaron25322
 
Python Environment Setup and Essentials modified.pptx
Python Environment Setup and Essentials modified.pptxPython Environment Setup and Essentials modified.pptx
Python Environment Setup and Essentials modified.pptxAnup Kelkar
 
Python.pptx
Python.pptxPython.pptx
Python.pptxabclara
 
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdfDr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdfRahulSingh190790
 
2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekingeProf. Wim Van Criekinge
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMohammed Rafi
 
Introduction to Python Programming Basics
Introduction  to  Python  Programming BasicsIntroduction  to  Python  Programming Basics
Introduction to Python Programming BasicsDhana malar
 
Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsAndrew McNicol
 

Similar to python.pptx (20)

Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
P1 2018 python
P1 2018 pythonP1 2018 python
P1 2018 python
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptx
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 
Python Environment Setup and Essentials modified.pptx
Python Environment Setup and Essentials modified.pptxPython Environment Setup and Essentials modified.pptx
Python Environment Setup and Essentials modified.pptx
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Python Intro
Python IntroPython Intro
Python Intro
 
Python_slides.pdf
Python_slides.pdfPython_slides.pdf
Python_slides.pdf
 
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdfDr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
Dr. Tanvi FOCP Unit-2 Session-1 PPT (Revised).pdf
 
P1 2017 python
P1 2017 pythonP1 2017 python
P1 2017 python
 
2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
What is python
What is pythonWhat is python
What is python
 
Introduction to Python Programming Basics
Introduction  to  Python  Programming BasicsIntroduction  to  Python  Programming Basics
Introduction to Python Programming Basics
 
Python 1
Python 1Python 1
Python 1
 
Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security Professionals
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 

Recently uploaded

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 

Recently uploaded (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 

python.pptx

  • 2. Outline • What is Python • History • Python Interpreter • Syntax and Semantics • Control Structures • basic types: numbers, strings • container types: lists, dictionaries, tuples • variables • control structures • functions & procedures • classes & instances • modules & packages • exceptions • files & standard library • Applications
  • 3. Python • Simple • Python is a simple and minimalistic language in nature • Reading a good python program should be like reading English • Its Pseudo-code nature allows one to concentrate on the problem rather than the language • Easy to Learn • Free & Open source • Freely distributed and Open source • Maintained by the Python community • High Level Language –memory management • Portable – *runs on anything c code will
  • 4. Python • Interpreted • You run the program straight from the source code. • Python program Bytecode a platforms native language • You can just copy over your code to another system and it will auto-magically work! *with python platform • Object-Oriented • Simple and additionally supports procedural programming • Extensible – easily import other code • Embeddable –easily place your code in non-python programs • Extensive libraries • (i.e. reg. expressions, doc generation, CGI, ftp, web browsers, ZIP, WAV, cryptography, etc...) (wxPython, Twisted, Python Imaging library)
  • 5. A Bit of History • Python was conceived in the late 1980s. • Guido van Rossum, Benevolent Dictator For Life • Rossum is Dutch, born in Netherlands, Christmas break bored, big fan of Monty python’s Flying Circus • Descendant of ABC programming language, he wrote glob() func in UNIX • Python 0.9.0 (initial version) was published in 1991 • Python 1.0 was released in 1994: included high-order functions (lambda, map, filter, and reduce. • Computer Programming for Everybody (CP4E) initiative • Launched by Rossum to make programming accessible to more people, with basic “literacy” similar to those required for English and math skills for some jobs. • Python 2.2 was released in 2001: Included unification of types and classes into one hierarchy, making pythons object model purely Object-oriented
  • 6. Python Interpreter • Interactive interface to Python % python Python 2.5 (r25:51908, May 25 2007, 16:14:04) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> • Python interpreter evaluates inputs: >>> 3*(7+2) 27 • Python prompts with ‘>>>’. • To exit Python: CTRL-D • Running on UNIX % python filename.py • You could make the *.py file executable and add: #!/usr/bin/env python to the top to make it runnable.
  • 10. Loops/Iterations • sentence = ['Marry','had','a','little','lamb’] • for word in sentence: print word, len(word) • for i in range(10): print i for i in xrange(1000): # does not allocate all initially print i • while True: pass • for i in xrange(10): if i == 3: continue if i == 5: break print i,
  • 11. Functions • def print_hello():# returns nothing print “hello” • def has_args(arg1,arg2=['e', 0]): num = arg1 + 4 mylist = arg2 + ['a',7] return [num, mylist] has_args(5.16,[1,'b'])# returns [9.16,[[1, ‘b’],[ ‘a’,7]] • def duplicate_n_maker(n): #lambda on the fly func. return lambda arg1:arg1*n dup3 = duplicate_n_maker(3) dup_str = dup3('go') # dup_str == 'gogogo'