SlideShare a Scribd company logo
Introduction to Python
Session 1
Named after Monty Python-British comedy group
Python is a general-purpose interpreted, interactive, object-oriented, and high-level
programming language. It was created by Guido van Rossum during 1985- 1990.
Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-
68, SmallTalk, and Unix shell and other scripting languages.
Python’s elegant syntax and dynamic typing, together with its interpreted nature, make
it an ideal language for scripting and rapid application development in many areas on
most platforms.
The Python interpreter and the extensive standard library are freely available in source
or binary form for all major platforms from the Python Web site, https://www.python.org/
Professionally, Python is great for backend web development, data analysis, artificial
intelligence, and scientific computing. Many developers have also used Python to build
productivity tools, games, and desktop apps.
• Scripting and Automation
It is a very useful capability that allows you to type in a program and to have it
executed immediately in an interactive mode.
The code is written in the form of scripts and get executed
Machine reads and interprets the code
Error checking is done during Runtime
Once the code is checked, it can be used several times. So by automation, you can
automate certain tasks in a program.
Why Python
Data Science
Python is the leading language of many data scientist.
For years, academic scholars and private researchers were using the MATLAB
language for scientific research but it all started to change with the release of
Python numerical engines such as ‘Numpy’ and ‘Pandas’.
Computer Graphics
Python is largely used in small, large, online or offline projects.
It is used to build GUI and desktop applications.
It uses ‘Tkinter‘ library to provide fast & easy way to create applications.
Artificial Intelligence
You can actually make a machine mimic the human brain which has the power to
think, analyze and make decisions.
Furthermore, libraries such as Keras and TensorFlow bring machine learning
functionality into the mix.
It gives the ability to learn without being explicitly programmed. Also, we have
libraries such as openCv that helps computer vision or image recognition.
Web Development
Python has an array of frameworks for developing websites.
The popular frameworks are Django, Flask, Pylons etc. Since these frameworks
are written in Python, its the core reason which makes the code a lot faster and
stable.
We can also perform web scraping where you can fetch details from any other
websites.
Portable & Extensible
The portable and extensible properties of Python allow you to perform cross-
language operations seamlessly.
Python is supported by most platforms present in the industry today ranging from
Windows to Linux to Macintosh, Solaris, Play station, among others.
Simple & Easy To Learn
• Python is Free & open source
• High-level
• Interpreted
• Blessed with large community
Installing Python
Python is preinstalled on most Unix or Linux
systems.
But for Windows Operating Systems user
can download from the
https://www.python.org/downloads/
From the link, download the latest version of
python IDE and install.
After Installing the Python go to start menu
you will find Python command line and IDLE
Python GUI.
Python Code Execution
Source code is translated to byte code, which is then run by the Python virtual
machine.
Code is automatically compiled but then it is interpreted.
Local Environment Setup
Open a terminal window and type "python" to find out if it is already installed and
which version is installed.
Setting up PATH
Programs and other executable files can be in many directories, so operating
systems provide a search path that lists the directories that the OS searches for
executables.
The path is stored in an environment variable, which is a named string maintained by
the operating system. This variable contains information available to the command
shell and other programs.
The path variable is named as PATH in Unix or Path in Windows
Setting path at Windows
To add the Python directory to the path for a particular session in Windows −
At the command prompt − type path %path%;C:Python and press Enter.
Note − C:Python is the path of the Python directory
Interactive Mode and Script Mode are the two main modes which are used in
Python Programming Language.
The basic differences between these two modes are as follows:
Interactive mode is used when an user wants to run one single line or one block
of code. It runs very quickly and gives the output instantly.
Example: Python command line.
Script Mode, on the other hand , is used when the user is working with more than
one single code or a block of code.
Example: IDLE Python GUI
Python Identifiers
A Python identifier is a name used to identify a variable, function, class, module or
other object.
An identifier 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).
Python does not allow punctuation characters such as @, $, and % within identifiers.
Python is a case sensitive programming language. Thus, a and A are two different
identifiers in Python.
Here are naming conventions for Python identifiers −
• Class names start with an uppercase letter. All other identifiers start with a
lowercase letter.
• Starting an identifier with a single leading underscore indicates that the identifier
is private.
• Starting an identifier with two leading underscores indicates a strongly private
identifier.
• If the identifier also ends with two trailing underscores, the identifier is a
language-defined special 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
These are reserved words and you cannot use them as constant or variable or any
other identifier names. All the Python keywords contain lowercase letters only.
Python uses indentation for blocks, instead of curly braces.
Both tabs and spaces are supported, but the standard indentation requires
standard Python code to use four spaces.
Lines and Indentation
if True:
print "True"
else:
print "False"
Thus, in Python all the continuous lines indented with same number of spaces would
form a block.
Comments in Python
A hash sign (#) that is not inside a string literal begins a comment.
All characters after the # and up to the end of the physical line are part of the
comment and the Python interpreter ignores them.
# First comment statement
print "Hello, Class!" # second comment
Output : Hello Class
Triple-quoted string is also ignored by Python interpreter and can be used as a
multiline comments:
'''
This is a multiline
comment.
'''
•
num1 = 1.5
num2 = 6.3
# Add two numbers
sum = num1 + num2
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Swapping of 2 Nos
x = 5
y = 10
x, y = y, x
print("x =", x)
print("y =", y)

More Related Content

Similar to Session-1_Introduction to Python.pptx

introduction of python in data science
introduction of python in data scienceintroduction of python in data science
introduction of python in data science
bhavesh lande
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
MohammadSamiuddin10
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
Tamer Ahmed Farrag, PhD
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
Manohar k
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
Kirti Verma
 
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Niraj Bharambe
 
Python Applications by The Knowledge Academy.docx
Python Applications by The Knowledge Academy.docxPython Applications by The Knowledge Academy.docx
Python Applications by The Knowledge Academy.docx
AbhinavSharma309481
 
Python Intro
Python IntroPython Intro
Python Intro
koppenolski
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
session5-Getting stated with Python.pdf
session5-Getting stated with Python.pdfsession5-Getting stated with Python.pdf
session5-Getting stated with Python.pdf
AyushDutta32
 
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
VaibhavKumarSinghkal
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Mohammed Rafi
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
KPDDRAVIDIAN
 
Python Programming Unit1_Aditya College of Engg & Tech
Python Programming Unit1_Aditya College of Engg & TechPython Programming Unit1_Aditya College of Engg & Tech
Python Programming Unit1_Aditya College of Engg & Tech
Ramanamurthy Banda
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfCSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
AbdulmalikAhmadLawan2
 
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
QA TrainingHub
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
BijuAugustian
 
Python for Beginners.docx
Python for Beginners.docxPython for Beginners.docx
Python for Beginners.docx
AbhinavSharma309481
 

Similar to Session-1_Introduction to Python.pptx (20)

introduction of python in data science
introduction of python in data scienceintroduction of python in data science
introduction of python in data science
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
 
Python Applications by The Knowledge Academy.docx
Python Applications by The Knowledge Academy.docxPython Applications by The Knowledge Academy.docx
Python Applications by The Knowledge Academy.docx
 
Python Intro
Python IntroPython Intro
Python Intro
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
session5-Getting stated with Python.pdf
session5-Getting stated with Python.pdfsession5-Getting stated with Python.pdf
session5-Getting stated with Python.pdf
 
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
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Python Programming Unit1_Aditya College of Engg & Tech
Python Programming Unit1_Aditya College of Engg & TechPython Programming Unit1_Aditya College of Engg & Tech
Python Programming Unit1_Aditya College of Engg & Tech
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfCSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
 
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
 
Fundamentals of python
Fundamentals of pythonFundamentals of python
Fundamentals of python
 
Python for Beginners.docx
Python for Beginners.docxPython for Beginners.docx
Python for Beginners.docx
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 

Session-1_Introduction to Python.pptx

  • 2. Named after Monty Python-British comedy group
  • 3. Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985- 1990. Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol- 68, SmallTalk, and Unix shell and other scripting languages. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, https://www.python.org/ Professionally, Python is great for backend web development, data analysis, artificial intelligence, and scientific computing. Many developers have also used Python to build productivity tools, games, and desktop apps.
  • 4. • Scripting and Automation It is a very useful capability that allows you to type in a program and to have it executed immediately in an interactive mode. The code is written in the form of scripts and get executed Machine reads and interprets the code Error checking is done during Runtime Once the code is checked, it can be used several times. So by automation, you can automate certain tasks in a program. Why Python
  • 5. Data Science Python is the leading language of many data scientist. For years, academic scholars and private researchers were using the MATLAB language for scientific research but it all started to change with the release of Python numerical engines such as ‘Numpy’ and ‘Pandas’. Computer Graphics Python is largely used in small, large, online or offline projects. It is used to build GUI and desktop applications. It uses ‘Tkinter‘ library to provide fast & easy way to create applications.
  • 6. Artificial Intelligence You can actually make a machine mimic the human brain which has the power to think, analyze and make decisions. Furthermore, libraries such as Keras and TensorFlow bring machine learning functionality into the mix. It gives the ability to learn without being explicitly programmed. Also, we have libraries such as openCv that helps computer vision or image recognition. Web Development Python has an array of frameworks for developing websites. The popular frameworks are Django, Flask, Pylons etc. Since these frameworks are written in Python, its the core reason which makes the code a lot faster and stable. We can also perform web scraping where you can fetch details from any other websites.
  • 7. Portable & Extensible The portable and extensible properties of Python allow you to perform cross- language operations seamlessly. Python is supported by most platforms present in the industry today ranging from Windows to Linux to Macintosh, Solaris, Play station, among others. Simple & Easy To Learn • Python is Free & open source • High-level • Interpreted • Blessed with large community
  • 8.
  • 9. Installing Python Python is preinstalled on most Unix or Linux systems. But for Windows Operating Systems user can download from the https://www.python.org/downloads/ From the link, download the latest version of python IDE and install. After Installing the Python go to start menu you will find Python command line and IDLE Python GUI.
  • 10. Python Code Execution Source code is translated to byte code, which is then run by the Python virtual machine. Code is automatically compiled but then it is interpreted.
  • 11. Local Environment Setup Open a terminal window and type "python" to find out if it is already installed and which version is installed.
  • 12. Setting up PATH Programs and other executable files can be in many directories, so operating systems provide a search path that lists the directories that the OS searches for executables. The path is stored in an environment variable, which is a named string maintained by the operating system. This variable contains information available to the command shell and other programs. The path variable is named as PATH in Unix or Path in Windows Setting path at Windows To add the Python directory to the path for a particular session in Windows − At the command prompt − type path %path%;C:Python and press Enter. Note − C:Python is the path of the Python directory
  • 13. Interactive Mode and Script Mode are the two main modes which are used in Python Programming Language. The basic differences between these two modes are as follows: Interactive mode is used when an user wants to run one single line or one block of code. It runs very quickly and gives the output instantly. Example: Python command line. Script Mode, on the other hand , is used when the user is working with more than one single code or a block of code. Example: IDLE Python GUI
  • 14.
  • 15. Python Identifiers A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier 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). Python does not allow punctuation characters such as @, $, and % within identifiers. Python is a case sensitive programming language. Thus, a and A are two different identifiers in Python.
  • 16. Here are naming conventions for Python identifiers − • Class names start with an uppercase letter. All other identifiers start with a lowercase letter. • Starting an identifier with a single leading underscore indicates that the identifier is private. • Starting an identifier with two leading underscores indicates a strongly private identifier. • If the identifier also ends with two trailing underscores, the identifier is a language-defined special name
  • 17. 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 These are reserved words and you cannot use them as constant or variable or any other identifier names. All the Python keywords contain lowercase letters only.
  • 18. Python uses indentation for blocks, instead of curly braces. Both tabs and spaces are supported, but the standard indentation requires standard Python code to use four spaces. Lines and Indentation if True: print "True" else: print "False" Thus, in Python all the continuous lines indented with same number of spaces would form a block.
  • 19. Comments in Python A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them. # First comment statement print "Hello, Class!" # second comment Output : Hello Class Triple-quoted string is also ignored by Python interpreter and can be used as a multiline comments: ''' This is a multiline comment. '''
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. num1 = 1.5 num2 = 6.3 # Add two numbers sum = num1 + num2 # Display the sum print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) Swapping of 2 Nos x = 5 y = 10 x, y = y, x print("x =", x) print("y =", y)