SlideShare a Scribd company logo
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

PDF
Python final ppt
PPTX
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
PPT
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
PPT
Pythonintroduction
PPTX
Python PPT by Sushil Sir.pptx
ODP
Learn python
PDF
Pythonfinalppt 170822121204
PPTX
4_Introduction to Python Programming.pptx
Python final ppt
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
Pythonintroduction
Python PPT by Sushil Sir.pptx
Learn python
Pythonfinalppt 170822121204
4_Introduction to Python Programming.pptx

Similar to python.pptx (20)

PDF
Tutorial on-python-programming
PPT
python introduction all the students.ppt
PPTX
Chapter - 1.pptx
PDF
Introduction to Python
PPTX
Chapter 2: Basics of programming pyton programming
PDF
Python Programing Bio computing,basic concepts lab,,
PPTX
Presentation new
PPTX
Python final presentation kirti ppt1
ODP
Programming Under Linux In Python
PPT
Python Introduction.ppt
ODP
An Intro to Python in 30 minutes
PDF
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
PPT
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
PPTX
python presntation 2.pptx
PDF
Introduction To Python For Beginners
PDF
Stu_Unit1_CSE1.pdf
PPT
Python ppt
PPTX
Introduction to python.pptx
PDF
intro.pptx (1).pdf
Tutorial on-python-programming
python introduction all the students.ppt
Chapter - 1.pptx
Introduction to Python
Chapter 2: Basics of programming pyton programming
Python Programing Bio computing,basic concepts lab,,
Presentation new
Python final presentation kirti ppt1
Programming Under Linux In Python
Python Introduction.ppt
An Intro to Python in 30 minutes
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
python presntation 2.pptx
Introduction To Python For Beginners
Stu_Unit1_CSE1.pdf
Python ppt
Introduction to python.pptx
intro.pptx (1).pdf

Recently uploaded (20)

PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPT
Mechanical Engineering MATERIALS Selection
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPT
Project quality management in manufacturing
PPTX
additive manufacturing of ss316l using mig welding
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Artificial Intelligence
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
PPT on Performance Review to get promotions
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Foundation to blockchain - A guide to Blockchain Tech
Mechanical Engineering MATERIALS Selection
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Project quality management in manufacturing
additive manufacturing of ss316l using mig welding
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Geodesy 1.pptx...............................................
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Artificial Intelligence
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Embodied AI: Ushering in the Next Era of Intelligent Systems
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CH1 Production IntroductoryConcepts.pptx
Fundamentals of safety and accident prevention -final (1).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT on Performance Review to get promotions
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...

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'