SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
Anomit Ghosh        Dhananjay Singh   Ankur Shrivastava
anomit@anomit.com   mail@djsh.net     ankur@ankurs.com
What We Will Learn

    History, Features and Basic Details
●



    Language Basics
●



    Control flow
●



    Functions
●



    Modules
●



    Data Structures
●



    File I/O
●
What is Python?

    Python is a general purpose, object
●


    oriented, high level, interpreted
    language

    Developed in early 90's by Guido Van
●


    Rossum

    Its Simple,    Portable, Open Source
●


    and Powerful
Where is it used?

    Google uses it for its web crawler
●


    and search engine

    Youtube is based on Python
●



    Disney uses it in Panda3d
●



    Bittorrent is implemented in Python
●



    Used extensively from Space Shuttles
●


    to Mobile Phones
Diff from C/C++/Java

    No   Pointers (similar to java)
●



    No prior Compilation to
●


    ByteCode(?), directly Interpreted

    Includes Garbage Collector(?)
●



    Can be used in Procedure(?)/
●


    Object(?) Oriented approach/style

    Very good for scripting
●
Versions Of Python

    What Do You mean By Versions??
●




    Major/Important Versions Currently

    Python 2.5
●



    Python 2.6
●



    Python 3.0
●



    So what will we use??
Why 2.5/2.6 and !3.0???

    Available on a Large Number of
●


    Systems

    Major Library's and Extensions
●


    available for 2.5/2.6 not 3.0

    <<<<MORE>>>>
●
Python Interpreter

    Interactive session

    What is it?
●



    Their Importance
●



    How to exit an Interactive session
●


    quit() or

    Ctrl + D on Unix-like Systems

    Ctrl + Z on windows
Language Basics
Indentation

    Indentation is very important
●



    There are no begin/end delimiters
●



    Physical lines & Logical lines
●



    Joining physical lines by /
●



    Use # for comments
●
Data Types

    Integer Numbers –> (dec) 1, 44;
●


    (oct) 01, 022;(hex) 0x1, 0x23;
    (long) 1L, 344343L

    Floating Point ->
●


    0.,0.0,323.23,2e3,23e32

    Complex numbers –> j = (-1) 1/2
●



       10+10j, -1+5j, 5-6j
Strings

    Strings can be single (',”) or triple
●


    (''',”””) quoted

    Character escaping by 
●



    Escape sequence - , ', ”,
●


    n, t
Tuple
    It is an Immutable(?) ordered
●


    sequence of items(?)

    Assigned-> a = (1122,1212,1212)
●



    Using tuples –> can be used as a
●


    constant array (but are much more)

    Data can be accessed similar to an
●


    array -> a=(132,3232,323)
             a[1] or a[3]
Lists

    List is a mutable ordered sequence
●


    of items (similar to tuple)

    Assigned-> a = [121,121212,34367]
●



    Using Lists -> simplest use is a
●


    arrays (but again are much more)

    Data can be accessed similar to an
●


    array -> a=[132,3232,323]
              a[1] or a[3]
Dictionaries
    Dictionaries are containers, which
●


    store items in a key/value pair(?)

    Assigned -> d ={'x':24,'y':33}
●



    Using Dict -> They are used at a
●


    lot of places (covered later)

    Data can be accessed by using the
●


    key ->
     d['x']
Variables
    There is no prior declaration needed
●



    Variables are the references(?) to
●


    the allocated memory(?)

    Variables can refer to any data type
●


    (like Tuple, List,Dictionary, Int,
    String, Complex)

    References are share
●



    List,Dict etc are always shared
●
Index and slices
    String, List, Tuple, etc can be
●


    sliced to get a part of them

    Index -> similar to array index, it
●


    refers to 1 position of data

    Slices-> gives the data in the range
●



    Example ->
●



       a=”LUG Manipal”
       a[:3]   a[4:11]   a[4:]   a[-7:]   a[:-8]   a[:11:2]
Control Flow
print

    Print is a simple statement for
●


    giving output similar to C's printf
    function

    Can be used to output to Console
●


    or a file

    Use -> print “Hello World”
●
input

    Use raw_input() to take a string
●


    input from the user

    Used as
●



    <var> = raw_input(“Enter a String: “)

    Input() in used to take a input
●


    without specifying the type
if
    If is a conditional statement, for
●


    simple “If then else“ clause in English

    Header lines(?) are always concluded
●


    with a “ : “ followed by intended
    block of statements

    Optionally it can be followed by an
●


    “else if” clause known as “elif” in
    python
If (con)
    Example->
●



    if <condition>:
●



        Statement 1
        Statement 2

    elif <condition>:
        Statements

    else:
        statements
while
    While statement is used for
●


    repeatedly executing a block of code
    till the condition is true, also has an
    optional else clause

    Use wildly for infinite loop
●
While (con)
    Example ->
●



    While <condition>:
●



        statements

    else:
        statements
for
    It is a sequence iterator(?)
●



    It works on Strings, lists, tuples,
●


    etc

    Example->
●



    For <target> in <iterable>:
●



          statements
range/xrange

    They are used to generate and
●


    return integer sequence(?)

    Range(5) -> [0,1,2,3,4]
●



    Range(1,5) -> [1,2,3,4]
●



    Range(0,8,2) -> [0,2,4,6]
●



    Xrange is used as a memory
●


    efficient(?) alternative for range
break

    Used to terminate a loop
●



    If nested(?) it terminates the inner
●


    most loop

    Practically used for conditional loop
●


    termination with an if statement
continue

    Terminates the current iteration and
●


    executes next

    Practically used for conditional
●


    statements termination with an if
    statement
Some Helpful Functions

    Dir()
●



    Help()
●
Functions
What are functions?

    A Function is a group of statements
●


    that execute on request

    In Python Functions are Objects
●



    Defining a function ->
●



    def name(parameters):
       statement(s)
Parameters

    Types of parameters
●



       Mandatory Parameters
       Optional parameters

    Defaults values
●



    Be careful when default value is a
●


    mutable object
Example

    Def a(x,y=[]):
●



       y.append(x)
       print y

    print a(12)

    print a(34)

    What just happened here?
●
Namespace

    A namespace is an abstract container
●


    or environment created to hold a
    logical grouping of unique(!)
    identifiers or symbols

    <<MORE>>
●
Nested Functions

    Def statement inside a function
●


    defines a nested function

    Useful sometimes
●



    Use Of Class preffered
●
Functions (con)

    Return
●



    Return Type
●



    Some Examples
●
Modules
Modules

    What are modules?
●



    How to load modules
●



    Effect on namespace
●



    Important modules
●



          OS
          SYS
      –
How To Make Modules?
Y is this Important
Python Workshop. LUG Maniapl

Mais conteúdo relacionado

Mais procurados

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
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE Saraswathi Murugan
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundationKevlin Henney
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingEelco Visser
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionEelco Visser
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco Visser
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)Sami Said
 
Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Jay Coskey
 
Python language data types
Python language data typesPython language data types
Python language data typesHoang Nguyen
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way PresentationAmira ElSharkawy
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...Maulik Borsaniya
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingEelco Visser
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 

Mais procurados (20)

Day2
Day2Day2
Day2
 
Knowledge Extraction
Knowledge ExtractionKnowledge Extraction
Knowledge Extraction
 
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)
 
Python basics
Python basicsPython basics
Python basics
 
Python
PythonPython
Python
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Learn Python The Hard Way Presentation
Learn Python The Hard Way PresentationLearn Python The Hard Way Presentation
Learn Python The Hard Way Presentation
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 
Java generics final
Java generics finalJava generics final
Java generics final
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 

Destaque

Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013
Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013
Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013buurtkwis
 
2ronde fietsen
2ronde fietsen2ronde fietsen
2ronde fietsenbuurtkwis
 
Buurtkwis maart 2011 Ronde Sporen in Arnhem
Buurtkwis maart 2011 Ronde Sporen in ArnhemBuurtkwis maart 2011 Ronde Sporen in Arnhem
Buurtkwis maart 2011 Ronde Sporen in Arnhembuurtkwis
 
Reducing Time Spent On Requirements
Reducing Time Spent On RequirementsReducing Time Spent On Requirements
Reducing Time Spent On RequirementsByron Workman
 
Dynamic Code Patterns: Extending Your Applications with Plugins
Dynamic Code Patterns: Extending Your Applications with PluginsDynamic Code Patterns: Extending Your Applications with Plugins
Dynamic Code Patterns: Extending Your Applications with Pluginsdoughellmann
 

Destaque (6)

Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013
Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013
Reuring bij Vitesse - Buurtkwis Lombok-Heijenoord Arnhem nr.13 - 22 maart 2013
 
2ronde fietsen
2ronde fietsen2ronde fietsen
2ronde fietsen
 
Buurtkwis maart 2011 Ronde Sporen in Arnhem
Buurtkwis maart 2011 Ronde Sporen in ArnhemBuurtkwis maart 2011 Ronde Sporen in Arnhem
Buurtkwis maart 2011 Ronde Sporen in Arnhem
 
Reducing Time Spent On Requirements
Reducing Time Spent On RequirementsReducing Time Spent On Requirements
Reducing Time Spent On Requirements
 
Dynamic Code Patterns: Extending Your Applications with Plugins
Dynamic Code Patterns: Extending Your Applications with PluginsDynamic Code Patterns: Extending Your Applications with Plugins
Dynamic Code Patterns: Extending Your Applications with Plugins
 
Mobi Vision 2.0
Mobi Vision 2.0Mobi Vision 2.0
Mobi Vision 2.0
 

Semelhante a Python Workshop. LUG Maniapl

python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slidejonycse
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAhmed Salama
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with PythonSushant Mane
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In PythonMarwan Osman
 
Python scripting kick off
Python scripting kick offPython scripting kick off
Python scripting kick offAndrea Gangemi
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on SessionDharmesh Tank
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Winl xf
 
Jerry Shea Resume And Addendum 5 2 09
Jerry  Shea Resume And Addendum 5 2 09Jerry  Shea Resume And Addendum 5 2 09
Jerry Shea Resume And Addendum 5 2 09gshea11
 
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi PetangMajlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi PetangImsamad
 
Agapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.comAgapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.comAntonio Silva
 
Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1Alejandra Perez
 
Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5Oregon Law Practice Management
 

Semelhante a Python Workshop. LUG Maniapl (20)

python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slide
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
Python scripting kick off
Python scripting kick offPython scripting kick off
Python scripting kick off
 
Core java
Core javaCore java
Core java
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on Session
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
 
MMBJ Shanzhai Culture
MMBJ Shanzhai CultureMMBJ Shanzhai Culture
MMBJ Shanzhai Culture
 
Jerry Shea Resume And Addendum 5 2 09
Jerry  Shea Resume And Addendum 5 2 09Jerry  Shea Resume And Addendum 5 2 09
Jerry Shea Resume And Addendum 5 2 09
 
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi PetangMajlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
Majlis Persaraan Pn.Hjh.Normah bersama guru-guru Sesi Petang
 
Agapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.comAgapornis Mansos - www.criadourosudica.blogspot.com
Agapornis Mansos - www.criadourosudica.blogspot.com
 
LoteríA Correcta
LoteríA CorrectaLoteríA Correcta
LoteríA Correcta
 
Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1Paulo Freire Pedagpogia 1
Paulo Freire Pedagpogia 1
 
Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5Washington Practitioners Significant Changes To Rpc 1.5
Washington Practitioners Significant Changes To Rpc 1.5
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Python Workshop. LUG Maniapl

  • 1. Anomit Ghosh Dhananjay Singh Ankur Shrivastava anomit@anomit.com mail@djsh.net ankur@ankurs.com
  • 2.
  • 3. What We Will Learn History, Features and Basic Details ● Language Basics ● Control flow ● Functions ● Modules ● Data Structures ● File I/O ●
  • 4.
  • 5. What is Python? Python is a general purpose, object ● oriented, high level, interpreted language Developed in early 90's by Guido Van ● Rossum Its Simple, Portable, Open Source ● and Powerful
  • 6. Where is it used? Google uses it for its web crawler ● and search engine Youtube is based on Python ● Disney uses it in Panda3d ● Bittorrent is implemented in Python ● Used extensively from Space Shuttles ● to Mobile Phones
  • 7. Diff from C/C++/Java No Pointers (similar to java) ● No prior Compilation to ● ByteCode(?), directly Interpreted Includes Garbage Collector(?) ● Can be used in Procedure(?)/ ● Object(?) Oriented approach/style Very good for scripting ●
  • 8. Versions Of Python What Do You mean By Versions?? ● Major/Important Versions Currently Python 2.5 ● Python 2.6 ● Python 3.0 ● So what will we use??
  • 9. Why 2.5/2.6 and !3.0??? Available on a Large Number of ● Systems Major Library's and Extensions ● available for 2.5/2.6 not 3.0 <<<<MORE>>>> ●
  • 10. Python Interpreter Interactive session What is it? ● Their Importance ● How to exit an Interactive session ● quit() or Ctrl + D on Unix-like Systems Ctrl + Z on windows
  • 12. Indentation Indentation is very important ● There are no begin/end delimiters ● Physical lines & Logical lines ● Joining physical lines by / ● Use # for comments ●
  • 13. Data Types Integer Numbers –> (dec) 1, 44; ● (oct) 01, 022;(hex) 0x1, 0x23; (long) 1L, 344343L Floating Point -> ● 0.,0.0,323.23,2e3,23e32 Complex numbers –> j = (-1) 1/2 ● 10+10j, -1+5j, 5-6j
  • 14. Strings Strings can be single (',”) or triple ● (''',”””) quoted Character escaping by ● Escape sequence - , ', ”, ● n, t
  • 15. Tuple It is an Immutable(?) ordered ● sequence of items(?) Assigned-> a = (1122,1212,1212) ● Using tuples –> can be used as a ● constant array (but are much more) Data can be accessed similar to an ● array -> a=(132,3232,323) a[1] or a[3]
  • 16. Lists List is a mutable ordered sequence ● of items (similar to tuple) Assigned-> a = [121,121212,34367] ● Using Lists -> simplest use is a ● arrays (but again are much more) Data can be accessed similar to an ● array -> a=[132,3232,323] a[1] or a[3]
  • 17. Dictionaries Dictionaries are containers, which ● store items in a key/value pair(?) Assigned -> d ={'x':24,'y':33} ● Using Dict -> They are used at a ● lot of places (covered later) Data can be accessed by using the ● key -> d['x']
  • 18. Variables There is no prior declaration needed ● Variables are the references(?) to ● the allocated memory(?) Variables can refer to any data type ● (like Tuple, List,Dictionary, Int, String, Complex) References are share ● List,Dict etc are always shared ●
  • 19. Index and slices String, List, Tuple, etc can be ● sliced to get a part of them Index -> similar to array index, it ● refers to 1 position of data Slices-> gives the data in the range ● Example -> ● a=”LUG Manipal” a[:3] a[4:11] a[4:] a[-7:] a[:-8] a[:11:2]
  • 21. print Print is a simple statement for ● giving output similar to C's printf function Can be used to output to Console ● or a file Use -> print “Hello World” ●
  • 22. input Use raw_input() to take a string ● input from the user Used as ● <var> = raw_input(“Enter a String: “) Input() in used to take a input ● without specifying the type
  • 23. if If is a conditional statement, for ● simple “If then else“ clause in English Header lines(?) are always concluded ● with a “ : “ followed by intended block of statements Optionally it can be followed by an ● “else if” clause known as “elif” in python
  • 24. If (con) Example-> ● if <condition>: ● Statement 1 Statement 2 elif <condition>: Statements else: statements
  • 25. while While statement is used for ● repeatedly executing a block of code till the condition is true, also has an optional else clause Use wildly for infinite loop ●
  • 26. While (con) Example -> ● While <condition>: ● statements else: statements
  • 27. for It is a sequence iterator(?) ● It works on Strings, lists, tuples, ● etc Example-> ● For <target> in <iterable>: ● statements
  • 28. range/xrange They are used to generate and ● return integer sequence(?) Range(5) -> [0,1,2,3,4] ● Range(1,5) -> [1,2,3,4] ● Range(0,8,2) -> [0,2,4,6] ● Xrange is used as a memory ● efficient(?) alternative for range
  • 29. break Used to terminate a loop ● If nested(?) it terminates the inner ● most loop Practically used for conditional loop ● termination with an if statement
  • 30. continue Terminates the current iteration and ● executes next Practically used for conditional ● statements termination with an if statement
  • 31. Some Helpful Functions Dir() ● Help() ●
  • 33. What are functions? A Function is a group of statements ● that execute on request In Python Functions are Objects ● Defining a function -> ● def name(parameters): statement(s)
  • 34. Parameters Types of parameters ● Mandatory Parameters Optional parameters Defaults values ● Be careful when default value is a ● mutable object
  • 35. Example Def a(x,y=[]): ● y.append(x) print y print a(12) print a(34) What just happened here? ●
  • 36. Namespace A namespace is an abstract container ● or environment created to hold a logical grouping of unique(!) identifiers or symbols <<MORE>> ●
  • 37. Nested Functions Def statement inside a function ● defines a nested function Useful sometimes ● Use Of Class preffered ●
  • 38.
  • 39. Functions (con) Return ● Return Type ● Some Examples ●
  • 41. Modules What are modules? ● How to load modules ● Effect on namespace ● Important modules ● OS SYS –
  • 42. How To Make Modules?
  • 43. Y is this Important