SlideShare a Scribd company logo
Python
Scope and
Application
02
Python
real-world
applications
and their scope
Installation
03
Understanding
the process of
installation of
python
Python Basics
04
Understanding
the basics of
python
Python:
Introduction
and Different
Versions
01
An introduction to
python programming
language, its versions,
and their comparative
study
Agenda
Python:
Introduction and
Different Versions
of Python
Python is a programming
language that was created by
Guido van Rossum
It was first released in 1991
Features of python
programming language
Easy to learn, easy to code
Object oriented elements
Platform independent
Interpreted
Python: Introduction
There are two major versions of python, python 2.0, and python 3.0.
• Python 2.0 was released in the year 2000.
• Python 3.0 was released in the year 2008.
• Python 3.0 is the latest major release of python, and we will be using this version to write codes.
Python: Versions
IMPORTANT!
Python 3.0 is NOT completely backward-compatible with python 2.0.
Python: Versions Comparison
Basis of comparison Python 3 Python 2
Release Date 2008 2000
Function print print ("hello") print "hello*
Division of Integers
Whenever two integers are divided, you get a float
value
When two integers are divided, you always provide
integer value.
Unicode In Python 3, default storing of strings is Unicode.
To store Unicode string value, you require to define
them with "u".
Syntax The syntax is simpler and easily understandable.
The syntax of Python 2 was comparatively difficult to
understand.
Rules of ordering
Comparisons
In this version. Rules of ordering comparisons have
been simplified.
Rules of ordering comparison are very complex.
Iteration
The new Range() function introduced to perform
iterations.
In Python 2, the xrange() is used for iterations.
Python is used for:
Machine Learning
Data Science
Web Application
Development
Game Development
Python: Applications
Library Use
pymongo Database connectivity
TensorFlow Performing high-level computation
Matplotlib Plotting numerical data
Pandas Data analysis
PyGame Develop games
• Machine learning is the study of computer algorithms that can improve automatically through
experience and by the use of data. It is a part of artificial intelligence.
• Machine Learning algorithms are fed with large amount of data and then these algorithms predict
outcomes of the given problems using python.
Machine Learning Algorithms in Python:
• Linear regression
• Decision tree
• Logistic regression
• Support Vector Machines (SVM)
• Naive Bayes
Python: Versions
Python for machine learning
• Data science is an interdisciplinary field that uses scientific methods, processes, algorithms, and systems
to extract knowledge and insights from noisy, structured, and unstructured data, and apply knowledge and
actionable insights from data across a broad range of application domains.
• Python is widely used for performing different data science operations on datasets like create, read,
update, delete (CRUD), visualize, etc.
Python: Versions
Python for data science
keras
sklearn
numpy
matplotlib
tensorflow
• Python offers many frameworks from which to choose from, including Bottle.py, Flask, CherryPy, Pyramid, Django and
web2py.
• These frameworks have been used to power some of the world's most popular sites such as Spotify, Mozilla, Reddit,
etc.
Python: Versions
Python for web application
• Python provides a built-in library called pygame, which used to develop the game.
• Pygame is a cross-platform library that is used to design video and browser games.
• We can use the pygame library to make games with attractive graphics and suitable animation.
Python: Versions
Python for game development
Python:
Installation
To download python, visit the following link:
Python: Installation
https://www.python.org/downloads/
Run the installer.
01
Make sure to select
“Add Python to
PATH” option on
bottom left corner
of the installer
window.
02
In case this option
was not selected, we
have to add path to
python installation in
PATH variable
manually.
03
Keep the default
values for the
remaining steps.
04
Python: Installation
• After installation is complete, to check the version of python installed on your system, use
“python --version” command in cmd window.
Python: Installation
“python --version” command in cmd window
• To write and execute python code in cmd, use “py”
Python: Installation
• An integrated development environment (IDE) is software for building applications that combines common
developer tools into a single graphical user interface (GUI).
• There are different types of IDEs like PyCharm, Visual Studio Code, etc.
• These IDEs are popularly used to develop complex applications in different frameworks.
• IDEs provide flexibility to use different programming languages like python, JavaScript, C++, etc.
Python: Integrated Development Environment (IDE)
To download PyCharm, visit the following link and click on download button:
Python: Pycharm IDE Installation
https://www.jetbrains.com/pycharm/
Python: Pycharm IDE Installation
Now, download community version installer by clicking download button below community.
Python: Pycharm IDE Installation
Run the PyCharm
installer.
01
Click next and you
can change the
destination folder
by clicking the
browse button.
02
Click on “create
desktop icon” button
and start installation
by clicking the install
button.
03
After installation,
click the finish
button.
04
• Visual Studio Code, also commonly referred as VS Code, is a source-code editor made by Microsoft
for Windows, Linux, and macOS.
• Features include support for debugging, syntax highlighting, intelligent code completion, snippets,
code refactoring, and embedded Git.
Python: Visual Studio Code
To download vs code, visit the following link and click on download button:
Python: Visual Studio Code Installation
https://code.visualstudio.com/download
Python: Visual Studio Code Installation
Run VScode
installer.
01
You can change
destination folder
for installation of
files.
02
Click “create desktop
icon” button.
03
Also, make sure
that you enable
“add to path” and
“Register code as
an editor for
supported files
type” button.
04
Then click on
next and install
button.
05
Create a file in vs code
with .py extension
Go to extensions > search
for “Python v2022.6.0” by
Microsoft.
Click install
Python: Visual Studio Code Installation
Hands-on
Python: Basics
• Unlike other programming languages such as java, there is no need to write too much boilerplate
code in python.
• To print a string/message on the console window, print function is used.
Our first python program: hello world!
Python: Basics
• Write the code given in the image in a file.
• Save it by the name “demo.py”
• Files containing python source code are saved with .py extension
Python: Basics
Our first python program: hello world!
• To execute the code present in a file, use “py file-name.py” command in cmd window.
Python: Basics
Our first python program: hello world!
• Take a number input from user and then display that number in output.
User input in python
Python: Basics
• There is no keyword to declare variables in python.
• Variables are created by writing the name and assigning the values.
• A single variable can be used to store values of different types.
Variable
Python: Basics
• Take age input in years from user and then calculate this age in days by multiplying age by 365.
• Find error in this code below.
Python program for calculating age in days
Python: Basics
Hands-on
• Some of the data-types present in python are:
▪ str
▪ int, float, complex
▪ bytes,
▪ bool
▪ list, set, tuple, range, dictionary
Variables and data types
Python: Basics
Numeric Dictionary Boolean Set
Sequence
Type
Integer Float
Complex
Number
Strings Tuple
List
Python – Data Types
• To check the type of a variable in python, type() is used.
Data types
Python: Basics
Code Output
Important!
String in python can be written using “ ” as well as ‘ ‘
Line by line execution and errors in python
Python: Basics
• In python, execution happens line by line meaning that the execution of the python program will
happen from top to down.
• Whatever line you have written at the top will be executed first and the rest of the lines will be
executed sequentially.
• If you do not follow the python language instructions or if you make a mistake while writing the
code, then python will give you an error message in console.
Line by line execution and errors in python
Python: Basics
• An example to the errors and sequential programming is displayed below.
• In this example “variable1” at line number 3, a variable is declared; it is access at line number 2,
where an error is shown.
• The error has occurred only at line number 2, but not in line 3 and 4, which get executed after this
error. Execution was stopped at line number 2.
Hands-on
• Operators are used to perform operations on data, which is either received from user or manually
entered.
• The operators are divided into following groups:
▪ Arithmetic operators
▪ Assignment operators
▪ Comparison operators
▪ Logical operators
▪ Identity operators
Membership operators most commonly used operators that we will discuss here are Arithmetic,
Comparison, Assignment and Logical operators.
Operators
Python: Basics
Arithmetic operators
Python: Basics
Operator Name Example
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
% Modulus x % y
** Exponentiation x ** y
// Floor division x // y
Arithmetic operators' hands on
Python: Basics
Assignment operators
Python: Basics
Operator Example Example same as below
= x = 5 x = 5
+= x += 3 x = x + 3
-= x -= 3 x = x - 3
*= x *= 3 x = x * 3
/= x /= 3 x = x / 3
%= x %= 3 x = x % 3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
Assignment operators' hands on
Python: Basics
Comparison operators
Python: Basics
Operator Name Example
== Equal x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>=
Greater than or
equal to
x >= y
<=
Less than or
equal to
x <= y
Comparison operators’ hands on
Python: Basics
Logical operators
Python: Basics
Operator Description Example
and
Returns True if both
statements are true
x < 5 and x < 10
or
Returns True if one of the
statements is true
x < 5 or x < 4
not
Reverse the result, returns
False if the result is true
not(x < 5 and x < 10)
Logical operators' hands on
Python: Basics
Hands-on
Python is a programming language that was created by Guido van Rossum.
It was first released in 1991.
It is easy to learn and easy to code language.
Unlike other programming languages such as java, there is no need to write too much boilerplate
code in python.
Use of famous code editors like Visual Studio code, PyCharm etc.
Different operators in python include Arithmetic, Comparison, Assignment and Logical operators.
Summary
Python: MCQs
Q1. Main difference between python 2 and python 3
a) Print is a statement in python 2 and a function in python 3.
b) Python 2 is syntactically difficult than python 3.
c) Python 3 is not completely backward-compatible with python 2.
d) Python 3 has more usage than python 2.
e) None of the above
Q2. Predict output of code given below
a = 10
a = 20
a = 30
a = 40
print(a)
a) 10
b) 20
c) 30
d) 40
e) None of the above
Python: MCQs
Q3. Predict output of code given below
a = 30
b = 40
print(a */ b)
a) 1200
b) 0.75
c) Error message “invalid syntax”
d) 40
e) None of the above
Q4. Predict output of code given below
a = True
b = False
print((a and b) or a)
a) True
b) False
c) Error message “invalid syntax”
d) None of the above
Python: MCQs
Q5. Predict output of code given below
a = 30
b = 40
c = 60
d = 100
print( (a <= 30 and b <=60) and (c == 60 or d <= 200))
a) True
b) False
c) Error message “invalid syntax”
d) None of the above
Q6. Predict output of code given below
a = 20
b = 20
c = a*b
print()
a) 400
b) 20
c) Error message “print function empty”
d) No output
e) None of the above
Python: MCQs
Q7. Predict output of code given below
a = 30
b = 40
c = 60
d = 100
print( (a <= 30 and b <=60) or (c == 60 and d <= 200))
a) True
b) False
c) Error message “invalid syntax”
d) None of the above
Q8. Predict output of code given below
a = 50
b = 60
c = 2000
d = 100
print( (a <= 30 or b <=60) or (c == 60 or d <= 200) )
a) True
b) False
c) Error message “invalid syntax”
d) None of the above
Python: MCQs
Q9. Predict output of code given below
a = 2
a **= 3
b = 20
b /= 10
print(a**b)
a) 20
b) 64.0
c) Error message “invalid syntax”
d) None of the above
Q10. Predict output of code given below
a = 50
b = 100
c = 200
print((a < 1000 and b > 50) and c > 10)
a) True
b) False
c) Error message “invalid syntax”
d) None of the above
Thank You!
Copyright © HeroX Private Limited, 2022. All rights reserved.

More Related Content

Similar to Introduction to Python.pdf

Python Programming.pptx
Python Programming.pptxPython Programming.pptx
Python Programming.pptx
DineshThakur911173
 
Python PPT.pptx
Python PPT.pptxPython PPT.pptx
Python PPT.pptx
JosephMuez2
 
Introduction to python3.pdf
Introduction to python3.pdfIntroduction to python3.pdf
Introduction to python3.pdf
Mohammed Aman Nawaz
 
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
 
Python tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyPython tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academy
TIB Academy
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
Kaviya452563
 
Python Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computerPython Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computer
sharanyarashmir5
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
MohammadSamiuddin10
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
Rajani S Togarsi
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
michaelaaron25322
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
lemonchoos
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
Ishaq Ali
 
Python intro
Python introPython intro
Python intro
Piyush rai
 
Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
Excellence Academy
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
Tamer Ahmed Farrag, PhD
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programmingChetan Giridhar
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
Kirti Verma
 
Exploring Five Lesser-Known Python Libraries
Exploring Five Lesser-Known Python LibrariesExploring Five Lesser-Known Python Libraries
Exploring Five Lesser-Known Python Libraries
MinhazulAbedin27
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
Ethan's Tech
 

Similar to Introduction to Python.pdf (20)

Python Programming.pptx
Python Programming.pptxPython Programming.pptx
Python Programming.pptx
 
Python PPT.pptx
Python PPT.pptxPython PPT.pptx
Python PPT.pptx
 
Introduction to python3.pdf
Introduction to python3.pdfIntroduction to python3.pdf
Introduction to python3.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
 
Python tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyPython tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academy
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
 
Python Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computerPython Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computer
 
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
Introduction to Python Introduction to Python
Introduction to Python
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
 
Python intro
Python introPython intro
Python intro
 
Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programming
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
Exploring Five Lesser-Known Python Libraries
Exploring Five Lesser-Known Python LibrariesExploring Five Lesser-Known Python Libraries
Exploring Five Lesser-Known Python Libraries
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
 

Recently uploaded

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
 
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)
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
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
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
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
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.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
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
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
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 

Introduction to Python.pdf

  • 2. Scope and Application 02 Python real-world applications and their scope Installation 03 Understanding the process of installation of python Python Basics 04 Understanding the basics of python Python: Introduction and Different Versions 01 An introduction to python programming language, its versions, and their comparative study Agenda
  • 4. Python is a programming language that was created by Guido van Rossum It was first released in 1991 Features of python programming language Easy to learn, easy to code Object oriented elements Platform independent Interpreted Python: Introduction
  • 5. There are two major versions of python, python 2.0, and python 3.0. • Python 2.0 was released in the year 2000. • Python 3.0 was released in the year 2008. • Python 3.0 is the latest major release of python, and we will be using this version to write codes. Python: Versions IMPORTANT! Python 3.0 is NOT completely backward-compatible with python 2.0.
  • 6. Python: Versions Comparison Basis of comparison Python 3 Python 2 Release Date 2008 2000 Function print print ("hello") print "hello* Division of Integers Whenever two integers are divided, you get a float value When two integers are divided, you always provide integer value. Unicode In Python 3, default storing of strings is Unicode. To store Unicode string value, you require to define them with "u". Syntax The syntax is simpler and easily understandable. The syntax of Python 2 was comparatively difficult to understand. Rules of ordering Comparisons In this version. Rules of ordering comparisons have been simplified. Rules of ordering comparison are very complex. Iteration The new Range() function introduced to perform iterations. In Python 2, the xrange() is used for iterations.
  • 7. Python is used for: Machine Learning Data Science Web Application Development Game Development Python: Applications Library Use pymongo Database connectivity TensorFlow Performing high-level computation Matplotlib Plotting numerical data Pandas Data analysis PyGame Develop games
  • 8. • Machine learning is the study of computer algorithms that can improve automatically through experience and by the use of data. It is a part of artificial intelligence. • Machine Learning algorithms are fed with large amount of data and then these algorithms predict outcomes of the given problems using python. Machine Learning Algorithms in Python: • Linear regression • Decision tree • Logistic regression • Support Vector Machines (SVM) • Naive Bayes Python: Versions Python for machine learning
  • 9. • Data science is an interdisciplinary field that uses scientific methods, processes, algorithms, and systems to extract knowledge and insights from noisy, structured, and unstructured data, and apply knowledge and actionable insights from data across a broad range of application domains. • Python is widely used for performing different data science operations on datasets like create, read, update, delete (CRUD), visualize, etc. Python: Versions Python for data science keras sklearn numpy matplotlib tensorflow
  • 10. • Python offers many frameworks from which to choose from, including Bottle.py, Flask, CherryPy, Pyramid, Django and web2py. • These frameworks have been used to power some of the world's most popular sites such as Spotify, Mozilla, Reddit, etc. Python: Versions Python for web application
  • 11. • Python provides a built-in library called pygame, which used to develop the game. • Pygame is a cross-platform library that is used to design video and browser games. • We can use the pygame library to make games with attractive graphics and suitable animation. Python: Versions Python for game development
  • 13. To download python, visit the following link: Python: Installation https://www.python.org/downloads/
  • 14. Run the installer. 01 Make sure to select “Add Python to PATH” option on bottom left corner of the installer window. 02 In case this option was not selected, we have to add path to python installation in PATH variable manually. 03 Keep the default values for the remaining steps. 04 Python: Installation
  • 15. • After installation is complete, to check the version of python installed on your system, use “python --version” command in cmd window. Python: Installation “python --version” command in cmd window
  • 16. • To write and execute python code in cmd, use “py” Python: Installation
  • 17. • An integrated development environment (IDE) is software for building applications that combines common developer tools into a single graphical user interface (GUI). • There are different types of IDEs like PyCharm, Visual Studio Code, etc. • These IDEs are popularly used to develop complex applications in different frameworks. • IDEs provide flexibility to use different programming languages like python, JavaScript, C++, etc. Python: Integrated Development Environment (IDE)
  • 18. To download PyCharm, visit the following link and click on download button: Python: Pycharm IDE Installation https://www.jetbrains.com/pycharm/
  • 19. Python: Pycharm IDE Installation Now, download community version installer by clicking download button below community.
  • 20. Python: Pycharm IDE Installation Run the PyCharm installer. 01 Click next and you can change the destination folder by clicking the browse button. 02 Click on “create desktop icon” button and start installation by clicking the install button. 03 After installation, click the finish button. 04
  • 21. • Visual Studio Code, also commonly referred as VS Code, is a source-code editor made by Microsoft for Windows, Linux, and macOS. • Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Python: Visual Studio Code
  • 22. To download vs code, visit the following link and click on download button: Python: Visual Studio Code Installation https://code.visualstudio.com/download
  • 23. Python: Visual Studio Code Installation Run VScode installer. 01 You can change destination folder for installation of files. 02 Click “create desktop icon” button. 03 Also, make sure that you enable “add to path” and “Register code as an editor for supported files type” button. 04 Then click on next and install button. 05
  • 24. Create a file in vs code with .py extension Go to extensions > search for “Python v2022.6.0” by Microsoft. Click install Python: Visual Studio Code Installation
  • 27. • Unlike other programming languages such as java, there is no need to write too much boilerplate code in python. • To print a string/message on the console window, print function is used. Our first python program: hello world! Python: Basics
  • 28. • Write the code given in the image in a file. • Save it by the name “demo.py” • Files containing python source code are saved with .py extension Python: Basics Our first python program: hello world!
  • 29. • To execute the code present in a file, use “py file-name.py” command in cmd window. Python: Basics Our first python program: hello world!
  • 30. • Take a number input from user and then display that number in output. User input in python Python: Basics
  • 31. • There is no keyword to declare variables in python. • Variables are created by writing the name and assigning the values. • A single variable can be used to store values of different types. Variable Python: Basics
  • 32. • Take age input in years from user and then calculate this age in days by multiplying age by 365. • Find error in this code below. Python program for calculating age in days Python: Basics
  • 34. • Some of the data-types present in python are: ▪ str ▪ int, float, complex ▪ bytes, ▪ bool ▪ list, set, tuple, range, dictionary Variables and data types Python: Basics Numeric Dictionary Boolean Set Sequence Type Integer Float Complex Number Strings Tuple List Python – Data Types
  • 35. • To check the type of a variable in python, type() is used. Data types Python: Basics Code Output Important! String in python can be written using “ ” as well as ‘ ‘
  • 36. Line by line execution and errors in python Python: Basics • In python, execution happens line by line meaning that the execution of the python program will happen from top to down. • Whatever line you have written at the top will be executed first and the rest of the lines will be executed sequentially. • If you do not follow the python language instructions or if you make a mistake while writing the code, then python will give you an error message in console.
  • 37. Line by line execution and errors in python Python: Basics • An example to the errors and sequential programming is displayed below. • In this example “variable1” at line number 3, a variable is declared; it is access at line number 2, where an error is shown. • The error has occurred only at line number 2, but not in line 3 and 4, which get executed after this error. Execution was stopped at line number 2.
  • 39. • Operators are used to perform operations on data, which is either received from user or manually entered. • The operators are divided into following groups: ▪ Arithmetic operators ▪ Assignment operators ▪ Comparison operators ▪ Logical operators ▪ Identity operators Membership operators most commonly used operators that we will discuss here are Arithmetic, Comparison, Assignment and Logical operators. Operators Python: Basics
  • 40. Arithmetic operators Python: Basics Operator Name Example + Addition x + y - Subtraction x - y * Multiplication x * y / Division x / y % Modulus x % y ** Exponentiation x ** y // Floor division x // y
  • 41. Arithmetic operators' hands on Python: Basics
  • 42. Assignment operators Python: Basics Operator Example Example same as below = x = 5 x = 5 += x += 3 x = x + 3 -= x -= 3 x = x - 3 *= x *= 3 x = x * 3 /= x /= 3 x = x / 3 %= x %= 3 x = x % 3 //= x //= 3 x = x // 3 **= x **= 3 x = x ** 3
  • 43. Assignment operators' hands on Python: Basics
  • 44. Comparison operators Python: Basics Operator Name Example == Equal x == y != Not equal x != y > Greater than x > y < Less than x < y >= Greater than or equal to x >= y <= Less than or equal to x <= y
  • 45. Comparison operators’ hands on Python: Basics
  • 46. Logical operators Python: Basics Operator Description Example and Returns True if both statements are true x < 5 and x < 10 or Returns True if one of the statements is true x < 5 or x < 4 not Reverse the result, returns False if the result is true not(x < 5 and x < 10)
  • 47. Logical operators' hands on Python: Basics
  • 49. Python is a programming language that was created by Guido van Rossum. It was first released in 1991. It is easy to learn and easy to code language. Unlike other programming languages such as java, there is no need to write too much boilerplate code in python. Use of famous code editors like Visual Studio code, PyCharm etc. Different operators in python include Arithmetic, Comparison, Assignment and Logical operators. Summary
  • 50. Python: MCQs Q1. Main difference between python 2 and python 3 a) Print is a statement in python 2 and a function in python 3. b) Python 2 is syntactically difficult than python 3. c) Python 3 is not completely backward-compatible with python 2. d) Python 3 has more usage than python 2. e) None of the above Q2. Predict output of code given below a = 10 a = 20 a = 30 a = 40 print(a) a) 10 b) 20 c) 30 d) 40 e) None of the above
  • 51. Python: MCQs Q3. Predict output of code given below a = 30 b = 40 print(a */ b) a) 1200 b) 0.75 c) Error message “invalid syntax” d) 40 e) None of the above Q4. Predict output of code given below a = True b = False print((a and b) or a) a) True b) False c) Error message “invalid syntax” d) None of the above
  • 52. Python: MCQs Q5. Predict output of code given below a = 30 b = 40 c = 60 d = 100 print( (a <= 30 and b <=60) and (c == 60 or d <= 200)) a) True b) False c) Error message “invalid syntax” d) None of the above Q6. Predict output of code given below a = 20 b = 20 c = a*b print() a) 400 b) 20 c) Error message “print function empty” d) No output e) None of the above
  • 53. Python: MCQs Q7. Predict output of code given below a = 30 b = 40 c = 60 d = 100 print( (a <= 30 and b <=60) or (c == 60 and d <= 200)) a) True b) False c) Error message “invalid syntax” d) None of the above Q8. Predict output of code given below a = 50 b = 60 c = 2000 d = 100 print( (a <= 30 or b <=60) or (c == 60 or d <= 200) ) a) True b) False c) Error message “invalid syntax” d) None of the above
  • 54. Python: MCQs Q9. Predict output of code given below a = 2 a **= 3 b = 20 b /= 10 print(a**b) a) 20 b) 64.0 c) Error message “invalid syntax” d) None of the above Q10. Predict output of code given below a = 50 b = 100 c = 200 print((a < 1000 and b > 50) and c > 10) a) True b) False c) Error message “invalid syntax” d) None of the above
  • 55. Thank You! Copyright © HeroX Private Limited, 2022. All rights reserved.