SlideShare a Scribd company logo
Becoming a PythonistBecoming a Pythonist
What is Python?
Python is a high-level, interpreted, interactive and object oriented-
scripting language
Python is a case sensitive programming language
Very clear syntax + large and comprehensive standard library
Can run on many platform: Windows, Linux, Mactonish
History of Python
Created in 1990 by Guido Von Rossum
Python is derived from many other languages, including ABC,
Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and other
scripting languages.
Why Python?
 Python is robust
 Python is flexible
 Designed to be easy to learn and use
 Clean, clear syntax
 Very few Keywords
 Highly Portable
 Python reduces time to market
 Python is free
Productivity
 Reduced development time
code is 2-10x times shorter than C, C++, Java
 Improved Program Maintenance
Code is extremely readable
 Less Training
Language is very easy to learn
What is it used for?
 Web Scripting
 Database applications
 GUI Applications
 Steering scientific Applications
 XML Processing
 Gaming, Images, Serial Ports, Robots and More..
Python Vs Java
 Code 5-10 times more concise
 Dynamic typing
 Much Quicker Development
No compilation Phase
Less typing
 Yes, it runs slower
But development is faster
 Python with Java - Jython
Becoming a Pythonist
Advantages
Readability
It Is Simple to Get Support
Fast to Learn
Reusability
Software quality
Developer Productivity
Program Portability
Support Libraries
Enjoyment
Interactive “Shell”
 Great for learning the language
 Great for experimenting with the library
 Type statements or expressions at prompt:
 $python
>>> print “Hello, World”
Hello, World
>>>
Variable Types
 Int a=1 a=1
 a=2 a=2
 Int b = a b=a
Basic Datatypes
Integers (default for numbers)
z = 5 / 2 # Answer is 2, integer division.
Floats
x = 3.456
Strings
Can use “” or ‘’ to specify. “abc” ‘abc’ (Same thing.)
“““a‘b“c”””
Boolean
True and False
Whitespace and Comment
 There are no braces to indicate blocks of code for class and
function definitions or flow control
 Standard indentation is 4 spaces or one tab
# First comment
if True:
print "True"
else:
print "False"
Look at a sample of code…
x = 34 - 23 # A comment.
y = “Hello” # Another one.
z = 3.45
if z == 3.45 or y == “Hello”:
x = x + 1
y = y + “ World” # String concat.
print x
print y
>>> 12
>>> Hello World
String Operations
>>> “hello”.upper()
‘HELLO’
>>> print “%s xyz %d” % (“abc”, 34)
abc xyz 34
>>> names = [“Ben", “Chen", “Yaqin"]
>>> ", ".join(names)
‘Ben, Chen, Yaqin‘
>>> " ".join(names)
'BenChenYaqin'
Lists
 Lists are similar to arrays in C
 It can store same data type as well as different data type.
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
>>> list[0]
'abcd'
>>> len(list)
5
>>> [1,2,3]+[4,5,6]
[1,2,3,4,5,6]
>>> range(1,5)
[1,2,3,4]
Built-in List Functions & Methods:
list = ['dora', 55, 'ram', 355.8]
>>> list.append(obj) : list.append('guru') → ['dora', 55, 'ram', 355.8,
'guru']
>>>list.count(obj) : list.count('ram') →1
>>>list.index(obj) : list.index(55) → 1
>>>list.remove(obj) : list.remove(355.8) → ['dora', 55, 'ram', 'guru']
>>>list.reverse() : list.reverse() → ['guru', 'ram', 55, 'dora']
>>>list.pop() : list.pop() → ['guru', 'ram', 55]
>>>list[0:2] : list[0:2] → ['guru', 'ram']
Tuples
 Tuples are sequences, just like lists.
 Tuples cannot be updated
 read-only lists
>>>tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
>>> tuple[0]
'abcd'
>>> len(tuple)
5
>>> (1,2,3)+(4,5,6)
(1,2,3,4,5,6)
>>>min(tuple)
2.23
Dictionary
 Dictionaries consist of pairs of keys and their corresponding
values.
 Duplicate key is not allowed.
 Keys must be immutable.
 Dictionaries are indexed by keys.
>>> dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'};
>>>dict['Name']
Zara
>>>del dict['Name']
{'Age': 7, 'Class': 'First'}
>>>len(dict)
2
Built-in Dictionary Functions
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'};
>>> dict.copy() : dict1 = dict.copy() → {'Name': 'Zara', 'Age':
7, 'Class': 'First'};
>>>dict.clear() : dict1.clear() →{}
>>>dict.get(key) : dict.get('Age') → 7
>>>dict.has_key(key) : dict.has_key('Age') → True
>>>dict.items() : dict.items() → [('Age', 7), ('Name',
'Zara'), ('Class', 'First')]
>>>dict.keys() : dict.keys() →['Age', 'Name', 'Class']
>>>dict.update(dict2) : dict.update(dict2)
>>>dict.values() : dict.values() → [7, 'Zara', 'First']
Python Loops
For Loop :
for n in range(1, 4):
print "This is the number"
While Loop:
n = 3
while n > 0:
print n, "is a nice number."
n = n – 1
Defining a Function
def sum(numbers):
"""Finds the sum of the numbers in a list."""
total = 0
for number in numbers:
total = total + number
return total
>>>sum(range(1, 5))
>>>10
Classes
 Classes usually have methods. Methods are functions which
always take an instance of the class as the first argument.
>>> Class Foo:
... def __init__(self):
... self.member = 1
... def get_member(self):
... return self.member
...
>>> f = Foo()
>>> f.get_member()
>>> 1
Python Modules
 Collection of stuff in foo.py file
 A module is a file consisting of Python code
 A module can define functions, classes, and variables.
 import math
content = dir(math)
['__doc__', '__file__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos',
'cosh', 'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp',
'log','log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']
Packages in Python
 Collection of modules in directory
 Must have __init__.py and contains subpackages.
 Consider a file Pots.py available in Phone directory.
Phone/Isdn.py file having function Isdn()
Phone/G3.py file having function G3()
 # Now import your Phone Package(__init__.py).
import Phone
Phone.Pots()
Phone.Isdn()
Phone.G3()
Python Exceptions Handling
 An exception is a Python object that represents an error.
 When a Python script raises an exception, it must either handle
the exception immediately otherwise it would terminate and
come out.
 try:
----
except Exception :
---
else:
---
 try:
---
finally:
---
Web Frameworks for Python
 Collection of packages or modules which allow developers to
write Web applications
 Zope2
 Web2py
 Pylons
 TurboGears
 Django
Thank You
Ad

More Related Content

What's hot (20)

Python in 90 minutes
Python in 90 minutesPython in 90 minutes
Python in 90 minutes
Bardia Heydari
 
Creating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonCreating Domain Specific Languages in Python
Creating Domain Specific Languages in Python
Siddhi
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
Matt Harrison
 
FUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCE
FUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCEFUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCE
FUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCE
Venugopalavarma Raja
 
Python dictionary : past, present, future
Python dictionary: past, present, futurePython dictionary: past, present, future
Python dictionary : past, present, future
delimitry
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ahmed Salama
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Python Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionPython Puzzlers - 2016 Edition
Python Puzzlers - 2016 Edition
Nandan Sawant
 
Matlab and Python: Basic Operations
Matlab and Python: Basic OperationsMatlab and Python: Basic Operations
Matlab and Python: Basic Operations
Wai Nwe Tun
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
Andrei Tomoroga
 
1st CI&T Lightning Talks: Writing better code with Object Calisthenics
1st CI&T Lightning Talks: Writing better code with Object Calisthenics1st CI&T Lightning Talks: Writing better code with Object Calisthenics
1st CI&T Lightning Talks: Writing better code with Object Calisthenics
Lucas Arruda
 
python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slide
jonycse
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
RajKumar Rampelli
 
FUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCE
FUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCEFUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCE
FUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCE
Venugopalavarma Raja
 
Session 02 python basics
Session 02 python basicsSession 02 python basics
Session 02 python basics
bodaceacat
 
Session 05 cleaning and exploring
Session 05 cleaning and exploringSession 05 cleaning and exploring
Session 05 cleaning and exploring
bodaceacat
 
C# - What's next
C# - What's nextC# - What's next
C# - What's next
Christian Nagel
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
Arturo Herrero
 
C# 7
C# 7C# 7
C# 7
Mike Harris
 
Python for Dummies
Python for DummiesPython for Dummies
Python for Dummies
Leonardo Jimenez
 
Creating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonCreating Domain Specific Languages in Python
Creating Domain Specific Languages in Python
Siddhi
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
Matt Harrison
 
FUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCE
FUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCEFUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCE
FUNCTIONS IN PYTHON. CBSE +2 COMPUTER SCIENCE
Venugopalavarma Raja
 
Python dictionary : past, present, future
Python dictionary: past, present, futurePython dictionary: past, present, future
Python dictionary : past, present, future
delimitry
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ahmed Salama
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Python Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionPython Puzzlers - 2016 Edition
Python Puzzlers - 2016 Edition
Nandan Sawant
 
Matlab and Python: Basic Operations
Matlab and Python: Basic OperationsMatlab and Python: Basic Operations
Matlab and Python: Basic Operations
Wai Nwe Tun
 
1st CI&T Lightning Talks: Writing better code with Object Calisthenics
1st CI&T Lightning Talks: Writing better code with Object Calisthenics1st CI&T Lightning Talks: Writing better code with Object Calisthenics
1st CI&T Lightning Talks: Writing better code with Object Calisthenics
Lucas Arruda
 
python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slide
jonycse
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
RajKumar Rampelli
 
FUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCE
FUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCEFUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCE
FUNCTIONS IN PYTHON, CLASS 12 COMPUTER SCIENCE
Venugopalavarma Raja
 
Session 02 python basics
Session 02 python basicsSession 02 python basics
Session 02 python basics
bodaceacat
 
Session 05 cleaning and exploring
Session 05 cleaning and exploringSession 05 cleaning and exploring
Session 05 cleaning and exploring
bodaceacat
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
Arturo Herrero
 

Viewers also liked (13)

Pommes
PommesPommes
Pommes
Evelha
 
Sajak warkah kepada generasi
Sajak warkah kepada generasiSajak warkah kepada generasi
Sajak warkah kepada generasi
shikinabdaziz
 
Minit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraan
Minit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraanMinit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraan
Minit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraan
Manz Zaini
 
Sajak: warkah kepada generasi tingkatan 2
Sajak: warkah kepada generasi tingkatan 2Sajak: warkah kepada generasi tingkatan 2
Sajak: warkah kepada generasi tingkatan 2
shikinabdaziz
 
ik/ ki proiektua
ik/ ki proiektuaik/ ki proiektua
ik/ ki proiektua
elja24
 
Rancangan pengajaran harian bahasa melayu tingkatan 2
Rancangan pengajaran harian bahasa melayu tingkatan 2 Rancangan pengajaran harian bahasa melayu tingkatan 2
Rancangan pengajaran harian bahasa melayu tingkatan 2
shikinabdaziz
 
Pentsamateka
PentsamatekaPentsamateka
Pentsamateka
elja24
 
Handiek txikiei laguntzen
Handiek txikiei laguntzenHandiek txikiei laguntzen
Handiek txikiei laguntzen
elja24
 
Handiek txikiei laguntzen
Handiek txikiei laguntzenHandiek txikiei laguntzen
Handiek txikiei laguntzen
elja24
 
Muestra de la semana de la fruta
Muestra de la semana de la frutaMuestra de la semana de la fruta
Muestra de la semana de la fruta
elja24
 
Réunion Clévacances 15 Mai 2008
Réunion Clévacances 15 Mai 2008Réunion Clévacances 15 Mai 2008
Réunion Clévacances 15 Mai 2008
breton80
 
La protection des données personnelles
La protection des données personnellesLa protection des données personnelles
La protection des données personnelles
breton80
 
Pommes
PommesPommes
Pommes
Evelha
 
Sajak warkah kepada generasi
Sajak warkah kepada generasiSajak warkah kepada generasi
Sajak warkah kepada generasi
shikinabdaziz
 
Minit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraan
Minit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraanMinit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraan
Minit mesyuarat panitia pendidikan sivik dan kenegaraan kewarganegaraan
Manz Zaini
 
Sajak: warkah kepada generasi tingkatan 2
Sajak: warkah kepada generasi tingkatan 2Sajak: warkah kepada generasi tingkatan 2
Sajak: warkah kepada generasi tingkatan 2
shikinabdaziz
 
ik/ ki proiektua
ik/ ki proiektuaik/ ki proiektua
ik/ ki proiektua
elja24
 
Rancangan pengajaran harian bahasa melayu tingkatan 2
Rancangan pengajaran harian bahasa melayu tingkatan 2 Rancangan pengajaran harian bahasa melayu tingkatan 2
Rancangan pengajaran harian bahasa melayu tingkatan 2
shikinabdaziz
 
Pentsamateka
PentsamatekaPentsamateka
Pentsamateka
elja24
 
Handiek txikiei laguntzen
Handiek txikiei laguntzenHandiek txikiei laguntzen
Handiek txikiei laguntzen
elja24
 
Handiek txikiei laguntzen
Handiek txikiei laguntzenHandiek txikiei laguntzen
Handiek txikiei laguntzen
elja24
 
Muestra de la semana de la fruta
Muestra de la semana de la frutaMuestra de la semana de la fruta
Muestra de la semana de la fruta
elja24
 
Réunion Clévacances 15 Mai 2008
Réunion Clévacances 15 Mai 2008Réunion Clévacances 15 Mai 2008
Réunion Clévacances 15 Mai 2008
breton80
 
La protection des données personnelles
La protection des données personnellesLa protection des données personnelles
La protection des données personnelles
breton80
 
Ad

Similar to Becoming a Pythonist (20)

Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
Larry Cai
 
Python_Fundamentals_for_Everyone_Usefull
Python_Fundamentals_for_Everyone_UsefullPython_Fundamentals_for_Everyone_Usefull
Python_Fundamentals_for_Everyone_Usefull
rravipssrivastava
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
Saraswathi Murugan
 
Introduction to learn and Python Interpreter
Introduction to learn and Python InterpreterIntroduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
Keep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce PythonKeep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce Python
SushJalai
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
Dan Bowen
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
Daniel Greenfeld
 
Lesson1 python an introduction
Lesson1 python an introductionLesson1 python an introduction
Lesson1 python an introduction
Arulalan T
 
Python for Engineers and Architects Stud
Python for Engineers and Architects StudPython for Engineers and Architects Stud
Python for Engineers and Architects Stud
RaviRamachandraR
 
Python-The programming Language
Python-The programming LanguagePython-The programming Language
Python-The programming Language
Rohan Gupta
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
sagar414433
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
sagar414433
 
Intro
IntroIntro
Intro
Daniel Greenfeld
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
OSU Open Source Lab
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
Mahmoud Samir Fayed
 
Sessisgytcfgggggggggggggggggggggggggggggggg
SessisgytcfggggggggggggggggggggggggggggggggSessisgytcfgggggggggggggggggggggggggggggggg
Sessisgytcfgggggggggggggggggggggggggggggggg
pawankamal3
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
krmboya
 
PYTHON
PYTHONPYTHON
PYTHON
JOHNYAMSON
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
Larry Cai
 
Python_Fundamentals_for_Everyone_Usefull
Python_Fundamentals_for_Everyone_UsefullPython_Fundamentals_for_Everyone_Usefull
Python_Fundamentals_for_Everyone_Usefull
rravipssrivastava
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Introduction to learn and Python Interpreter
Introduction to learn and Python InterpreterIntroduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
Keep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce PythonKeep it Stupidly Simple Introduce Python
Keep it Stupidly Simple Introduce Python
SushJalai
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
Dan Bowen
 
Lesson1 python an introduction
Lesson1 python an introductionLesson1 python an introduction
Lesson1 python an introduction
Arulalan T
 
Python for Engineers and Architects Stud
Python for Engineers and Architects StudPython for Engineers and Architects Stud
Python for Engineers and Architects Stud
RaviRamachandraR
 
Python-The programming Language
Python-The programming LanguagePython-The programming Language
Python-The programming Language
Rohan Gupta
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
sagar414433
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
sagar414433
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
Mahmoud Samir Fayed
 
Sessisgytcfgggggggggggggggggggggggggggggggg
SessisgytcfggggggggggggggggggggggggggggggggSessisgytcfgggggggggggggggggggggggggggggggg
Sessisgytcfgggggggggggggggggggggggggggggggg
pawankamal3
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
krmboya
 
Ad

Recently uploaded (20)

puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 

Becoming a Pythonist

  • 2. What is Python? Python is a high-level, interpreted, interactive and object oriented- scripting language Python is a case sensitive programming language Very clear syntax + large and comprehensive standard library Can run on many platform: Windows, Linux, Mactonish
  • 3. History of Python Created in 1990 by Guido Von Rossum Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and other scripting languages.
  • 4. Why Python?  Python is robust  Python is flexible  Designed to be easy to learn and use  Clean, clear syntax  Very few Keywords  Highly Portable  Python reduces time to market  Python is free
  • 5. Productivity  Reduced development time code is 2-10x times shorter than C, C++, Java  Improved Program Maintenance Code is extremely readable  Less Training Language is very easy to learn
  • 6. What is it used for?  Web Scripting  Database applications  GUI Applications  Steering scientific Applications  XML Processing  Gaming, Images, Serial Ports, Robots and More..
  • 7. Python Vs Java  Code 5-10 times more concise  Dynamic typing  Much Quicker Development No compilation Phase Less typing  Yes, it runs slower But development is faster  Python with Java - Jython
  • 9. Advantages Readability It Is Simple to Get Support Fast to Learn Reusability Software quality Developer Productivity Program Portability Support Libraries Enjoyment
  • 10. Interactive “Shell”  Great for learning the language  Great for experimenting with the library  Type statements or expressions at prompt:  $python >>> print “Hello, World” Hello, World >>>
  • 11. Variable Types  Int a=1 a=1  a=2 a=2  Int b = a b=a
  • 12. Basic Datatypes Integers (default for numbers) z = 5 / 2 # Answer is 2, integer division. Floats x = 3.456 Strings Can use “” or ‘’ to specify. “abc” ‘abc’ (Same thing.) “““a‘b“c””” Boolean True and False
  • 13. Whitespace and Comment  There are no braces to indicate blocks of code for class and function definitions or flow control  Standard indentation is 4 spaces or one tab # First comment if True: print "True" else: print "False"
  • 14. Look at a sample of code… x = 34 - 23 # A comment. y = “Hello” # Another one. z = 3.45 if z == 3.45 or y == “Hello”: x = x + 1 y = y + “ World” # String concat. print x print y >>> 12 >>> Hello World
  • 15. String Operations >>> “hello”.upper() ‘HELLO’ >>> print “%s xyz %d” % (“abc”, 34) abc xyz 34 >>> names = [“Ben", “Chen", “Yaqin"] >>> ", ".join(names) ‘Ben, Chen, Yaqin‘ >>> " ".join(names) 'BenChenYaqin'
  • 16. Lists  Lists are similar to arrays in C  It can store same data type as well as different data type. list = [ 'abcd', 786 , 2.23, 'john', 70.2 ] >>> list[0] 'abcd' >>> len(list) 5 >>> [1,2,3]+[4,5,6] [1,2,3,4,5,6] >>> range(1,5) [1,2,3,4]
  • 17. Built-in List Functions & Methods: list = ['dora', 55, 'ram', 355.8] >>> list.append(obj) : list.append('guru') → ['dora', 55, 'ram', 355.8, 'guru'] >>>list.count(obj) : list.count('ram') →1 >>>list.index(obj) : list.index(55) → 1 >>>list.remove(obj) : list.remove(355.8) → ['dora', 55, 'ram', 'guru'] >>>list.reverse() : list.reverse() → ['guru', 'ram', 55, 'dora'] >>>list.pop() : list.pop() → ['guru', 'ram', 55] >>>list[0:2] : list[0:2] → ['guru', 'ram']
  • 18. Tuples  Tuples are sequences, just like lists.  Tuples cannot be updated  read-only lists >>>tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 ) >>> tuple[0] 'abcd' >>> len(tuple) 5 >>> (1,2,3)+(4,5,6) (1,2,3,4,5,6) >>>min(tuple) 2.23
  • 19. Dictionary  Dictionaries consist of pairs of keys and their corresponding values.  Duplicate key is not allowed.  Keys must be immutable.  Dictionaries are indexed by keys. >>> dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}; >>>dict['Name'] Zara >>>del dict['Name'] {'Age': 7, 'Class': 'First'} >>>len(dict) 2
  • 20. Built-in Dictionary Functions dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}; >>> dict.copy() : dict1 = dict.copy() → {'Name': 'Zara', 'Age': 7, 'Class': 'First'}; >>>dict.clear() : dict1.clear() →{} >>>dict.get(key) : dict.get('Age') → 7 >>>dict.has_key(key) : dict.has_key('Age') → True >>>dict.items() : dict.items() → [('Age', 7), ('Name', 'Zara'), ('Class', 'First')] >>>dict.keys() : dict.keys() →['Age', 'Name', 'Class'] >>>dict.update(dict2) : dict.update(dict2) >>>dict.values() : dict.values() → [7, 'Zara', 'First']
  • 21. Python Loops For Loop : for n in range(1, 4): print "This is the number" While Loop: n = 3 while n > 0: print n, "is a nice number." n = n – 1
  • 22. Defining a Function def sum(numbers): """Finds the sum of the numbers in a list.""" total = 0 for number in numbers: total = total + number return total >>>sum(range(1, 5)) >>>10
  • 23. Classes  Classes usually have methods. Methods are functions which always take an instance of the class as the first argument. >>> Class Foo: ... def __init__(self): ... self.member = 1 ... def get_member(self): ... return self.member ... >>> f = Foo() >>> f.get_member() >>> 1
  • 24. Python Modules  Collection of stuff in foo.py file  A module is a file consisting of Python code  A module can define functions, classes, and variables.  import math content = dir(math) ['__doc__', '__file__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log','log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']
  • 25. Packages in Python  Collection of modules in directory  Must have __init__.py and contains subpackages.  Consider a file Pots.py available in Phone directory. Phone/Isdn.py file having function Isdn() Phone/G3.py file having function G3()  # Now import your Phone Package(__init__.py). import Phone Phone.Pots() Phone.Isdn() Phone.G3()
  • 26. Python Exceptions Handling  An exception is a Python object that represents an error.  When a Python script raises an exception, it must either handle the exception immediately otherwise it would terminate and come out.  try: ---- except Exception : --- else: ---  try: --- finally: ---
  • 27. Web Frameworks for Python  Collection of packages or modules which allow developers to write Web applications  Zope2  Web2py  Pylons  TurboGears  Django