SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Python Programming
Š copyright : spiraltrain@gmail.com
Course Schedule
• Python Intro
• Variables and Data Types
• Data Structures
• Control Flow and Operators
• Functions
• Modules
• Comprehensions
• Exception Handling
• Python IO
• Python Database Access
• Python Classes
• Optional : Python Libraries
2
• What is Python?
• Python Features
• History of Python
• Getting Started
• Setting up PATH
• Running Python
• Python in Interactive Mode
• Python in Script Mode
• Python Identifiers
• Python Reserved Words
• Comments in Python
• Lines and Indentation
• Multi Line Statements
• Quotes in Python
www.spiraltrain.nl
What is Python?
• Python is a general purpose high-level scripting language :
• Supports many applications from text processing to WWW browsers and games
• Python is Beginner's Language :
• Great language for the beginner programmers
• Python is interpreted :
• Processed at runtime by the interpreter like Perl and PHP code
• No need to compile your program before executing it
• Python is interactive :
• Prompt allows you to interact with the interpreter directly to write your programs
• Python is Object Oriented :
• Supports Object-Oriented style programming that encapsulates code within objects
• Python is easy to learn and easy to read :
• Python has relatively few keywords, simple structure, and a clearly defined syntax
• Python code is much more clearly defined and visible to the eye
3Python Intro
www.spiraltrain.nl
Python Features
• Broad standard library :
• Bulk of the library is cross portable on UNIX, Windows, and Macintosh
• Portable :
• Python runs on a wide variety of platforms and has same interface on all platforms
• Extendable :
• Python allows the addition of low-level modules to the Python interpreter
• Databases :
• Python provides interfaces to all major commercial databases
• GUI Programming :
• Python supports GUI applications that can be ported to many system calls
• Web Applications :
• Django and Flask Framework allow building of Python Web Applications
• Scalable :
• Python provides better structure and support for large programs than shell scripting
• Supports automatic garbage collection :
• Can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java
4Python Intro
www.spiraltrain.nl
History of Python
• Python was developed by Guido van Rossum around 1990 at :
• National Research Institute for Mathematics and Computer Science in Netherlands
• Python is derived from many other languages :
• Including Modula-3, C, C++,SmallTalk, Unix shell and other scripting languages
• Python is usable as :
• Scripting language or compiled to byte-code for building large applications
• Python is copyrighted and Python source code available :
• Like Perl under the GNU General Public License (GPL)
• Python is maintained by a development team at the institute :
• Guido van Rossum still holds a vital role in directing it's progress
• Python supports :
• Functional and structured programming methods as well as OOP
• Very high-level dynamic data types and dynamic type checking
5Python Intro
www.spiraltrain.nl
Getting Started
• Python Official Website :
• http://www.python.org/
• Has most up-to-date and current source code and binaries
• Both Python 2 and Python 3 are available which differ significantly
• Linux Installation :
• Download the zipped source code available for Unix/Linux
• Extract files and enter make install
• This will install Python in a standard location /usr/local/bin
• Windows Installation :
• Download the Windows installer python-XYZ.msi file
• Double-click the msi file and run the Python installation wizard
• Accept the default settings or choose an installation directory
• Python Documentation Website :
• www.python.org/doc/
• Documentation available in HTML, PDF and PostScript format
6Python Intro
www.spiraltrain.nl
Setting up PATH
• To invoke the Python interpreter from any particular directory :
• Add the Python directory to your path
• PATH is an environment variable :
• Provides a search path that lists directories that OS searches for executables
• Named PATH in Unix or Path in Windows
• Unix is case-sensitive, Windows is not
• Setting PATH in Linux :
• In the bash shell type :
export PATH="$PATH:/usr/local/bin/python" and press Enter
• Setting PATH in Windows :
• At a command prompt type :
PATH=%PATH%;C:Python and press Enter
• Or use the environment variables tab under System Properties
• PYTHONPATH :
• Tells Python interpreter where to locate module files you import into a program
7Python Intro
www.spiraltrain.nl
Running Python
• Invoke Python interpreter from any particular directory :
• Add the Python directory to your path
• Interactive Interpreter :
• Start the Python interactive interpreter from command line by entering python :
• You will get $python in Linux and >>> in Windows or Anaconda prompt with IPython
• Script can be parameterized with command line arguments C: python -h :
• Script from Command Line :
• A Python script can be executed at command line by invoking the interpreter
$ python script.py in Linux
C:> python script.py in Windows
• Integrated Development Environment :
• Run Python from a graphical user interface (GUI) environment
• GUI IDE for Python on system that supports Python is IDLE
• Jupyter Notebook on a web server :
• Give command jupyter notebook from Anaconda prompt
8Language Syntax
www.spiraltrain.nl
Python in Interactive Mode
• Python language has many similarities to Perl, C, and Java :
• There are some definite differences between the languages
• Start with Hello World Python program in interactive mode :
• Invoking interpreter by typing python in a command prompt :
• Type following right of the python prompt and press Enter :
>>> print ("Hello, Python!")
• This will produce following result :
Hello, Python!
• Separate multiple statements with a semicolon ;
9Python Intro
www.spiraltrain.nl
Python in Script Mode
• When the interpreter is invoked with a script parameter :
• The script begins execution and continues until it is finished
• When the script is finished, the interpreter is no longer active
• All Python files will have extension .py :
• Put the following source code in a test.py file
print ("Hello, Python!")
• Run the script as follows :
C: python test.py
• In a Unix environment make file executable with :
$ chmod +x test.py # set execute permission
• This will produce following result :
Hello, Python!
• print() default prints a new line
10Python Intro
Demo
01_hellopython
www.spiraltrain.nl
Python Identifiers
• Names used to identify things in Python :
• Variable, function, class, module, or other object
• Identifier Rules :
• Starts with a letter A to Z or a to z or an underscore (_)
• Followed by zero or more letters, underscores, and digits (0 to 9)
• Punctuation characters such as @, $, and % not allowed within identifiers
• Python is a case sensitive programming language :
• myVar and Myvar are different
• Naming conventions for Python :
• Class names start with uppercase letters, all other identifiers with lowercase letters
• Leading underscore is a weak private indicator :
— from M import * does not import objects with name starting with an underscore
• Two leading underscores indicates a strongly private identifier :
— Name mangling is applied to such identifiers by putting class name in front
• If identifier also ends with two trailing underscores :
— identifier is a language-defined special name 11Python Intro
www.spiraltrain.nl
Python Reserved Words
• May not be used as constant or variable or other identifier name
and exec not
assert finally or
break for pass
class from print
continue global raise
def if return
del import try
elif in while
else is with
except lambda yield
12Python Intro
www.spiraltrain.nl
Comments in Python
• Comments starts with :
• A hash sign (#) that is not inside a string literal
• All characters after the # and up to the physical line end are part of the comment
# First comment
print ("Hello, Python!") # second comment
• Will produce following result :
Hello, Python!
• Comment may be on same line after statement or expression :
name = "Einstein" # This is again comment
• Comment multiple lines as follows :
# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.
13Python Intro
www.spiraltrain.nl
Lines and Indentation
• Blocks of code are denoted by line indentation :
• No braces for blocks of code for class and function definitions or flow control
• Number of spaces in the indentation is variable :
• All statements within the block must be indented the same amount
if True: # Both blocks in first example are fine
print ("True")
else:
print ("False")
• Other example :
if True: # Second line in second block will generate an error
print ("Answer")
print ("True")
else:
print ("Answer")
print ("False")
• print() without new line is written as follows :
print ('hello python', end='')
• Semicolon ; allows multiple statements on single line 14Language Syntax
Demo
02_lines_and_identation
www.spiraltrain.nl
Multi Line Statements
• Statements in Python typically end with a newline
• Python allows the use of the line continuation character () :
• Denotes that the line should continue
total = item_one + 
item_two + 
item_three
• Statements contained within the [], {}, or () brackets :
• No need to use the line continuation character
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday']
• On a single line :
• Semicolon ( ; ) allows multiple statements on single line
• Neither statement should start a new code block
15Python Intro
Demo
03_multilinestatements
www.spiraltrain.nl
Quotes in Python
• Python uses quotes to denote string literals :
• single ('), double (") and triple (''' or """)
• Same type of quote should start and end the string
• Triple quotes can be used to span the string across multiple lines
print ('hello' + " " + '''world''')
word = 'word'
sentence = "This is a sentence."
paragraph = """This is a paragraph. It is made up of
multiple lines and sentences."""
• Single quote in a single quoted string :
• Displayed with an escape character 
'What 's your name'
16Python Intro
Demo
04_quotesandescapes
Š copyright : spiraltrain@gmail.com
Summary : Python Intro
• Python is a general purpose high-level scripting language :
• It is interpreted, interactive and object oriented
• Python was developed by Guido van Rossum around 1990 at :
• National Research Institute for Mathematics and Computer Science in Netherlands
• Python can be started in three different ways :
• Interactive Interpreter, Script from Command Line, from inside an IDE, Jupyter Notebook
• Python is a case sensitive programming language :
• myVar and Myvar are different
• Python uses line indentation to denote blocks of code :
• No braces for blocks of code for class and function definitions or flow control
• Python allows the use of the line continuation character () :
• Denote that the line should continue
• Python uses quotes to denote string literals :
• single ('), double (") and triple (''' or """)
Python Intro 17
Exercise 1
Environment Configuration

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMohammed Rafi
 
About Python Programming Language | Benefit of Python
About Python Programming Language | Benefit of PythonAbout Python Programming Language | Benefit of Python
About Python Programming Language | Benefit of PythonInformation Technology
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1Kanchilug
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialQA TrainingHub
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothBhavsingh Maloth
 
Programming with \'C\'
Programming with \'C\'Programming with \'C\'
Programming with \'C\'bdmsts
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-pythonAakashdata
 
Introduction to Python Programing
Introduction to Python ProgramingIntroduction to Python Programing
Introduction to Python Programingsameer patil
 
Getting Started with Python
Getting Started with PythonGetting Started with Python
Getting Started with PythonSankhya_Analytics
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonRanjith kumar
 
Python presentation by Monu Sharma
Python presentation by Monu SharmaPython presentation by Monu Sharma
Python presentation by Monu SharmaMayank Sharma
 
Python Programming
Python ProgrammingPython Programming
Python ProgrammingRenieMathews
 
2018 20 best id es for python programming
2018 20 best id es for python programming2018 20 best id es for python programming
2018 20 best id es for python programmingSyedBrothersRealEsta
 

Was ist angesagt? (19)

Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
About Python Programming Language | Benefit of Python
About Python Programming Language | Benefit of PythonAbout Python Programming Language | Benefit of Python
About Python Programming Language | Benefit of Python
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
Plc part 1
Plc part 1Plc part 1
Plc part 1
 
Programming with \'C\'
Programming with \'C\'Programming with \'C\'
Programming with \'C\'
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Introduction to Python Programing
Introduction to Python ProgramingIntroduction to Python Programing
Introduction to Python Programing
 
Getting Started with Python
Getting Started with PythonGetting Started with Python
Getting Started with Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Why learn python in 2017?
Why learn python in 2017?Why learn python in 2017?
Why learn python in 2017?
 
Python presentation by Monu Sharma
Python presentation by Monu SharmaPython presentation by Monu Sharma
Python presentation by Monu Sharma
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
2018 20 best id es for python programming
2018 20 best id es for python programming2018 20 best id es for python programming
2018 20 best id es for python programming
 

Ähnlich wie Python Intro

Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxWajidAliHashmi2
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfshetoooelshitany74
 
Python Programming.pdf
Python Programming.pdfPython Programming.pdf
Python Programming.pdfssuser9a6ca1
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdfpercivalfernandez2
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdfpercivalfernandez2
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdfpercivalfernandez2
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unitmichaelaaron25322
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptxGnanesh12
 
Lecture1_introduction to python.pptx
Lecture1_introduction to python.pptxLecture1_introduction to python.pptx
Lecture1_introduction to python.pptxMohammedAlYemeni1
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptxFrancis Densil Raj
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1Kirti Verma
 
Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfVaibhavKumarSinghkal
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdfsamiwaris2
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfSanjeedaPraween
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxlemonchoos
 
Introduction to Python.pdf
Introduction to Python.pdfIntroduction to Python.pdf
Introduction to Python.pdfRahul Mogal
 
Python for katana
Python for katanaPython for katana
Python for katanakedar nath
 

Ähnlich wie Python Intro (20)

Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptx
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
 
Python Programming.pdf
Python Programming.pdfPython Programming.pdf
Python Programming.pdf
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx
 
Lecture1_introduction to python.pptx
Lecture1_introduction to python.pptxLecture1_introduction to python.pptx
Lecture1_introduction to python.pptx
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdf
 
Python programming 2nd
Python programming 2ndPython programming 2nd
Python programming 2nd
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdf
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 
Introduction to Python.pdf
Introduction to Python.pdfIntroduction to Python.pdf
Introduction to Python.pdf
 
Python for katana
Python for katanaPython for katana
Python for katana
 

Mehr von koppenolski

Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScriptkoppenolski
 
HTML Intro
HTML IntroHTML Intro
HTML Introkoppenolski
 
Spring Boot
Spring BootSpring Boot
Spring Bootkoppenolski
 
Wicket Intro
Wicket IntroWicket Intro
Wicket Introkoppenolski
 
Intro apache
Intro apacheIntro apache
Intro apachekoppenolski
 

Mehr von koppenolski (8)

Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
HTML Intro
HTML IntroHTML Intro
HTML Intro
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Wicket Intro
Wicket IntroWicket Intro
Wicket Intro
 
R Intro
R IntroR Intro
R Intro
 
SQL Intro
SQL IntroSQL Intro
SQL Intro
 
UML Intro
UML IntroUML Intro
UML Intro
 
Intro apache
Intro apacheIntro apache
Intro apache
 

KĂźrzlich hochgeladen

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto GonzĂĄlez Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

KĂźrzlich hochgeladen (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

Python Intro

  • 2. Š copyright : spiraltrain@gmail.com Course Schedule • Python Intro • Variables and Data Types • Data Structures • Control Flow and Operators • Functions • Modules • Comprehensions • Exception Handling • Python IO • Python Database Access • Python Classes • Optional : Python Libraries 2 • What is Python? • Python Features • History of Python • Getting Started • Setting up PATH • Running Python • Python in Interactive Mode • Python in Script Mode • Python Identifiers • Python Reserved Words • Comments in Python • Lines and Indentation • Multi Line Statements • Quotes in Python
  • 3. www.spiraltrain.nl What is Python? • Python is a general purpose high-level scripting language : • Supports many applications from text processing to WWW browsers and games • Python is Beginner's Language : • Great language for the beginner programmers • Python is interpreted : • Processed at runtime by the interpreter like Perl and PHP code • No need to compile your program before executing it • Python is interactive : • Prompt allows you to interact with the interpreter directly to write your programs • Python is Object Oriented : • Supports Object-Oriented style programming that encapsulates code within objects • Python is easy to learn and easy to read : • Python has relatively few keywords, simple structure, and a clearly defined syntax • Python code is much more clearly defined and visible to the eye 3Python Intro
  • 4. www.spiraltrain.nl Python Features • Broad standard library : • Bulk of the library is cross portable on UNIX, Windows, and Macintosh • Portable : • Python runs on a wide variety of platforms and has same interface on all platforms • Extendable : • Python allows the addition of low-level modules to the Python interpreter • Databases : • Python provides interfaces to all major commercial databases • GUI Programming : • Python supports GUI applications that can be ported to many system calls • Web Applications : • Django and Flask Framework allow building of Python Web Applications • Scalable : • Python provides better structure and support for large programs than shell scripting • Supports automatic garbage collection : • Can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java 4Python Intro
  • 5. www.spiraltrain.nl History of Python • Python was developed by Guido van Rossum around 1990 at : • National Research Institute for Mathematics and Computer Science in Netherlands • Python is derived from many other languages : • Including Modula-3, C, C++,SmallTalk, Unix shell and other scripting languages • Python is usable as : • Scripting language or compiled to byte-code for building large applications • Python is copyrighted and Python source code available : • Like Perl under the GNU General Public License (GPL) • Python is maintained by a development team at the institute : • Guido van Rossum still holds a vital role in directing it's progress • Python supports : • Functional and structured programming methods as well as OOP • Very high-level dynamic data types and dynamic type checking 5Python Intro
  • 6. www.spiraltrain.nl Getting Started • Python Official Website : • http://www.python.org/ • Has most up-to-date and current source code and binaries • Both Python 2 and Python 3 are available which differ significantly • Linux Installation : • Download the zipped source code available for Unix/Linux • Extract files and enter make install • This will install Python in a standard location /usr/local/bin • Windows Installation : • Download the Windows installer python-XYZ.msi file • Double-click the msi file and run the Python installation wizard • Accept the default settings or choose an installation directory • Python Documentation Website : • www.python.org/doc/ • Documentation available in HTML, PDF and PostScript format 6Python Intro
  • 7. www.spiraltrain.nl Setting up PATH • To invoke the Python interpreter from any particular directory : • Add the Python directory to your path • PATH is an environment variable : • Provides a search path that lists directories that OS searches for executables • Named PATH in Unix or Path in Windows • Unix is case-sensitive, Windows is not • Setting PATH in Linux : • In the bash shell type : export PATH="$PATH:/usr/local/bin/python" and press Enter • Setting PATH in Windows : • At a command prompt type : PATH=%PATH%;C:Python and press Enter • Or use the environment variables tab under System Properties • PYTHONPATH : • Tells Python interpreter where to locate module files you import into a program 7Python Intro
  • 8. www.spiraltrain.nl Running Python • Invoke Python interpreter from any particular directory : • Add the Python directory to your path • Interactive Interpreter : • Start the Python interactive interpreter from command line by entering python : • You will get $python in Linux and >>> in Windows or Anaconda prompt with IPython • Script can be parameterized with command line arguments C: python -h : • Script from Command Line : • A Python script can be executed at command line by invoking the interpreter $ python script.py in Linux C:> python script.py in Windows • Integrated Development Environment : • Run Python from a graphical user interface (GUI) environment • GUI IDE for Python on system that supports Python is IDLE • Jupyter Notebook on a web server : • Give command jupyter notebook from Anaconda prompt 8Language Syntax
  • 9. www.spiraltrain.nl Python in Interactive Mode • Python language has many similarities to Perl, C, and Java : • There are some definite differences between the languages • Start with Hello World Python program in interactive mode : • Invoking interpreter by typing python in a command prompt : • Type following right of the python prompt and press Enter : >>> print ("Hello, Python!") • This will produce following result : Hello, Python! • Separate multiple statements with a semicolon ; 9Python Intro
  • 10. www.spiraltrain.nl Python in Script Mode • When the interpreter is invoked with a script parameter : • The script begins execution and continues until it is finished • When the script is finished, the interpreter is no longer active • All Python files will have extension .py : • Put the following source code in a test.py file print ("Hello, Python!") • Run the script as follows : C: python test.py • In a Unix environment make file executable with : $ chmod +x test.py # set execute permission • This will produce following result : Hello, Python! • print() default prints a new line 10Python Intro Demo 01_hellopython
  • 11. www.spiraltrain.nl Python Identifiers • Names used to identify things in Python : • Variable, function, class, module, or other object • Identifier Rules : • Starts with a letter A to Z or a to z or an underscore (_) • Followed by zero or more letters, underscores, and digits (0 to 9) • Punctuation characters such as @, $, and % not allowed within identifiers • Python is a case sensitive programming language : • myVar and Myvar are different • Naming conventions for Python : • Class names start with uppercase letters, all other identifiers with lowercase letters • Leading underscore is a weak private indicator : — from M import * does not import objects with name starting with an underscore • Two leading underscores indicates a strongly private identifier : — Name mangling is applied to such identifiers by putting class name in front • If identifier also ends with two trailing underscores : — identifier is a language-defined special name 11Python Intro
  • 12. www.spiraltrain.nl Python Reserved Words • May not be used as constant or variable or other identifier name and exec not assert finally or break for pass class from print continue global raise def if return del import try elif in while else is with except lambda yield 12Python Intro
  • 13. www.spiraltrain.nl Comments in Python • Comments starts with : • A hash sign (#) that is not inside a string literal • All characters after the # and up to the physical line end are part of the comment # First comment print ("Hello, Python!") # second comment • Will produce following result : Hello, Python! • Comment may be on same line after statement or expression : name = "Einstein" # This is again comment • Comment multiple lines as follows : # This is a comment. # This is a comment, too. # This is a comment, too. # I said that already. 13Python Intro
  • 14. www.spiraltrain.nl Lines and Indentation • Blocks of code are denoted by line indentation : • No braces for blocks of code for class and function definitions or flow control • Number of spaces in the indentation is variable : • All statements within the block must be indented the same amount if True: # Both blocks in first example are fine print ("True") else: print ("False") • Other example : if True: # Second line in second block will generate an error print ("Answer") print ("True") else: print ("Answer") print ("False") • print() without new line is written as follows : print ('hello python', end='') • Semicolon ; allows multiple statements on single line 14Language Syntax Demo 02_lines_and_identation
  • 15. www.spiraltrain.nl Multi Line Statements • Statements in Python typically end with a newline • Python allows the use of the line continuation character () : • Denotes that the line should continue total = item_one + item_two + item_three • Statements contained within the [], {}, or () brackets : • No need to use the line continuation character days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] • On a single line : • Semicolon ( ; ) allows multiple statements on single line • Neither statement should start a new code block 15Python Intro Demo 03_multilinestatements
  • 16. www.spiraltrain.nl Quotes in Python • Python uses quotes to denote string literals : • single ('), double (") and triple (''' or """) • Same type of quote should start and end the string • Triple quotes can be used to span the string across multiple lines print ('hello' + " " + '''world''') word = 'word' sentence = "This is a sentence." paragraph = """This is a paragraph. It is made up of multiple lines and sentences.""" • Single quote in a single quoted string : • Displayed with an escape character 'What 's your name' 16Python Intro Demo 04_quotesandescapes
  • 17. Š copyright : spiraltrain@gmail.com Summary : Python Intro • Python is a general purpose high-level scripting language : • It is interpreted, interactive and object oriented • Python was developed by Guido van Rossum around 1990 at : • National Research Institute for Mathematics and Computer Science in Netherlands • Python can be started in three different ways : • Interactive Interpreter, Script from Command Line, from inside an IDE, Jupyter Notebook • Python is a case sensitive programming language : • myVar and Myvar are different • Python uses line indentation to denote blocks of code : • No braces for blocks of code for class and function definitions or flow control • Python allows the use of the line continuation character () : • Denote that the line should continue • Python uses quotes to denote string literals : • single ('), double (") and triple (''' or """) Python Intro 17 Exercise 1 Environment Configuration