SlideShare ist ein Scribd-Unternehmen logo
1 von 16
By
Karthik Prakash
• Introduction to Python

• Interactive “Shell”

• Basic Types and Containers

• Control Structures
“Remarkable power with very clear syntax”

Python is an Interpreted, Object Oriented
Programming language.

…it’s named after a television series Monty Python’s
Flying Circus

It was created by Guido Van Rossum in the year
1990…
Features :-
• Free and Open Source… Maintained by the PSF (Python Software
  Foundation)

• Rapid Prototyping

• Compiled to interpreted byte code .. sometimes called as Scripting
  language
     ….i.e Compilation is implicit

• Indentation for block structure
…“Life's better without braces(Bruce Eckel)”

• Extremely Portable (Windows,Linux,Unix,Mac… etc)

• Powerful Standard libraries
Two variations: IDLE (GUI) and PYTHON (command line)

• Most Python implementations work on CLI (Command Line Interface)

• Great for learning the language by experimenting with the library

• Great for testing your own modules

• Benefits of IDLE

•   Multi Windows Text Editor
•   Interactive Command Shell
•   Syntax Highlighting
•   Auto-Indentation
•   Auto Completion extended to Intellisence
•   None
•   Numbers and Floats
•   Complex Numbers …. (i + j)
•   Floating point
•   Boolean…. True or False
•   “Strings”
•   u“Unicode”
•   Tuples ()
•   Lists []
•   Dictonaries {}

• Built-in Function “type()”
• If, else, elif….

• Try and except

• While Loop

• For Loop
• List Comprehension

• Functions

• Doc Strings
    … Smart way of Documenting modules

• File Handling
    …… read , write , append to file
Single

 [ <item operation> for item in sequence <if condition>]

Nested

Special care has to be taken for the nested list
comprehension:

….when nesting list comprehensions, read from right to
left.
Function Definition :-

def name (arg1, arg2…. , argn)
  “““ Documentation ””” #optional
  statements
        .
        .
        .
  return expression

  name(arg1,arg2) # Call to <name>
File Modes

• Mode Meaning
• 'r' open for reading (default)

• 'w' open for writing, truncating the file first

• 'a' open for writing, appending to the end of the file if it
  exists

• 'b' binary mode
f = open(filename, [mode])

• read(), readline(), readlines()

• write(), writelines()

• seek(pos), tell()

• close()
• Classes
  o   Class Definition

  o   Class Objects

  o   Class Data members

  o   Class Methods

  o   Class Inheritance
class Stack:
"A well-known data structure…"
def __init__(self): # constructor
self.items = []
def push(self, x):
self.items.append(x) #. Push into the Stack…the sky is the limit
def pop(self):
x = self.items[-1] # Pop from the stack
del self.items[-1]
return x
def empty(self):
return len(self.items) == 0 # Boolean result
object = Stack() #--- Object of the Class “Stack”

….. Constructor invoked during Object instantiation


object.push(arg1) #---- Call to Class Method “push”


print object.items #---- Access the Class Data Member
• class BaseClass:

    baseDataVar = 10
    def baseMethods(self)
    statements

    class DerivedClass(BaseClass):

    def Method()
    print self.baseDataVar
    self.baseMethods() #-- Call to base class method

Weitere ähnliche Inhalte

Was ist angesagt?

PhpStorm Cheat Sheet
PhpStorm Cheat SheetPhpStorm Cheat Sheet
PhpStorm Cheat SheetKamrul Hasan
 
Who go Types in my Systems Programing!
Who go Types in my Systems Programing!Who go Types in my Systems Programing!
Who go Types in my Systems Programing!Jared Roesch
 
Linux basics by Raj Miraje
Linux basics by Raj MirajeLinux basics by Raj Miraje
Linux basics by Raj MirajeRaj Mirje
 
Python intro and competitive programming
Python intro and competitive programmingPython intro and competitive programming
Python intro and competitive programmingSuraj Shah
 
Prototype 패턴 (심만섭)
Prototype 패턴 (심만섭) Prototype 패턴 (심만섭)
Prototype 패턴 (심만섭) YoungSu Son
 
Anonymous classes2
Anonymous classes2Anonymous classes2
Anonymous classes2Mark Baker
 

Was ist angesagt? (7)

Python programming
Python programmingPython programming
Python programming
 
PhpStorm Cheat Sheet
PhpStorm Cheat SheetPhpStorm Cheat Sheet
PhpStorm Cheat Sheet
 
Who go Types in my Systems Programing!
Who go Types in my Systems Programing!Who go Types in my Systems Programing!
Who go Types in my Systems Programing!
 
Linux basics by Raj Miraje
Linux basics by Raj MirajeLinux basics by Raj Miraje
Linux basics by Raj Miraje
 
Python intro and competitive programming
Python intro and competitive programmingPython intro and competitive programming
Python intro and competitive programming
 
Prototype 패턴 (심만섭)
Prototype 패턴 (심만섭) Prototype 패턴 (심만섭)
Prototype 패턴 (심만섭)
 
Anonymous classes2
Anonymous classes2Anonymous classes2
Anonymous classes2
 

Ähnlich wie Python Kick Start

Ähnlich wie Python Kick Start (20)

Python ppt
Python pptPython ppt
Python ppt
 
Python basic
Python basicPython basic
Python basic
 
Ruby1_full
Ruby1_fullRuby1_full
Ruby1_full
 
Ruby1_full
Ruby1_fullRuby1_full
Ruby1_full
 
Python3
Python3Python3
Python3
 
Python first day
Python first dayPython first day
Python first day
 
Python first day
Python first dayPython first day
Python first day
 
Python assignment help
Python assignment helpPython assignment help
Python assignment help
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
 
Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...Processing data with Python, using standard library modules you (probably) ne...
Processing data with Python, using standard library modules you (probably) ne...
 
Python - Lecture 9
Python - Lecture 9Python - Lecture 9
Python - Lecture 9
 
Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part I
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
From Java to Python: beating the Stockholm syndrome
From Java to Python: beating the Stockholm syndromeFrom Java to Python: beating the Stockholm syndrome
From Java to Python: beating the Stockholm syndrome
 
05io
05io05io
05io
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Java01
Java01Java01
Java01
 
Java01
Java01Java01
Java01
 
Java01
Java01Java01
Java01
 

Kürzlich hochgeladen

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Kürzlich hochgeladen (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

Python Kick Start

  • 2. • Introduction to Python • Interactive “Shell” • Basic Types and Containers • Control Structures
  • 3. “Remarkable power with very clear syntax” Python is an Interpreted, Object Oriented Programming language. …it’s named after a television series Monty Python’s Flying Circus It was created by Guido Van Rossum in the year 1990…
  • 4. Features :- • Free and Open Source… Maintained by the PSF (Python Software Foundation) • Rapid Prototyping • Compiled to interpreted byte code .. sometimes called as Scripting language ….i.e Compilation is implicit • Indentation for block structure …“Life's better without braces(Bruce Eckel)” • Extremely Portable (Windows,Linux,Unix,Mac… etc) • Powerful Standard libraries
  • 5. Two variations: IDLE (GUI) and PYTHON (command line) • Most Python implementations work on CLI (Command Line Interface) • Great for learning the language by experimenting with the library • Great for testing your own modules • Benefits of IDLE • Multi Windows Text Editor • Interactive Command Shell • Syntax Highlighting • Auto-Indentation • Auto Completion extended to Intellisence
  • 6. None • Numbers and Floats • Complex Numbers …. (i + j) • Floating point • Boolean…. True or False • “Strings” • u“Unicode” • Tuples () • Lists [] • Dictonaries {} • Built-in Function “type()”
  • 7. • If, else, elif…. • Try and except • While Loop • For Loop
  • 8. • List Comprehension • Functions • Doc Strings … Smart way of Documenting modules • File Handling …… read , write , append to file
  • 9. Single [ <item operation> for item in sequence <if condition>] Nested Special care has to be taken for the nested list comprehension: ….when nesting list comprehensions, read from right to left.
  • 10. Function Definition :- def name (arg1, arg2…. , argn) “““ Documentation ””” #optional statements . . . return expression name(arg1,arg2) # Call to <name>
  • 11. File Modes • Mode Meaning • 'r' open for reading (default) • 'w' open for writing, truncating the file first • 'a' open for writing, appending to the end of the file if it exists • 'b' binary mode
  • 12. f = open(filename, [mode]) • read(), readline(), readlines() • write(), writelines() • seek(pos), tell() • close()
  • 13. • Classes o Class Definition o Class Objects o Class Data members o Class Methods o Class Inheritance
  • 14. class Stack: "A well-known data structure…" def __init__(self): # constructor self.items = [] def push(self, x): self.items.append(x) #. Push into the Stack…the sky is the limit def pop(self): x = self.items[-1] # Pop from the stack del self.items[-1] return x def empty(self): return len(self.items) == 0 # Boolean result
  • 15. object = Stack() #--- Object of the Class “Stack” ….. Constructor invoked during Object instantiation object.push(arg1) #---- Call to Class Method “push” print object.items #---- Access the Class Data Member
  • 16. • class BaseClass: baseDataVar = 10 def baseMethods(self) statements class DerivedClass(BaseClass): def Method() print self.baseDataVar self.baseMethods() #-- Call to base class method