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

PPTX
Python introduction towards data science
PDF
Sessisgytcfgggggggggggggggggggggggggggggggg
PPTX
Python Demo.pptx
PPTX
Python Demo.pptx
DOCX
A Introduction Book of python For Beginners.docx
PDF
The Python for beginners. This is an advance computer language.
PPTX
lecture 2.pptx
PPT
Spsl iv unit final
Python introduction towards data science
Sessisgytcfgggggggggggggggggggggggggggggggg
Python Demo.pptx
Python Demo.pptx
A Introduction Book of python For Beginners.docx
The Python for beginners. This is an advance computer language.
lecture 2.pptx
Spsl iv unit final

Similar to Introduction to Python.pdf (20)

PPT
Spsl iv unit final
PDF
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
PPTX
Keep it Stupidly Simple Introduce Python
PPTX
4_Introduction to Python Programming.pptx
PPTX
Python PPT.pptx
PDF
python-handbook.pdf
PDF
Python basics_ part1
PPTX
UNIT 1 PYTHON introduction and basic level
PPTX
Lecture1_introduction to python.pptx
PPTX
Lecture on Fundamentals of Python Programming-1
PPTX
Python basics
PDF
Tutorial on-python-programming
PDF
Python basic programing language for automation
PDF
05 python.pdf
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
PDF
Introduction-to-Python-print-datatype.pdf
PPTX
Learn about Python power point presentation
PPTX
Python Programming-1.pptx of python by computer
PPTX
Python_ppt for basics of python in details
Spsl iv unit final
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
Keep it Stupidly Simple Introduce Python
4_Introduction to Python Programming.pptx
Python PPT.pptx
python-handbook.pdf
Python basics_ part1
UNIT 1 PYTHON introduction and basic level
Lecture1_introduction to python.pptx
Lecture on Fundamentals of Python Programming-1
Python basics
Tutorial on-python-programming
Python basic programing language for automation
05 python.pdf
Basic concept of Python.pptx includes design tool, identifier, variables.
Introduction-to-Python-print-datatype.pdf
Learn about Python power point presentation
Python Programming-1.pptx of python by computer
Python_ppt for basics of python in details
Ad

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Classroom Observation Tools for Teachers
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
master seminar digital applications in india
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Cell Types and Its function , kingdom of life
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Pre independence Education in Inndia.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PDF
Basic Mud Logging Guide for educational purpose
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
RMMM.pdf make it easy to upload and study
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Classroom Observation Tools for Teachers
TR - Agricultural Crops Production NC III.pdf
GDM (1) (1).pptx small presentation for students
master seminar digital applications in india
PPH.pptx obstetrics and gynecology in nursing
Cell Types and Its function , kingdom of life
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Complications of Minimal Access Surgery at WLH
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pre independence Education in Inndia.pdf
O7-L3 Supply Chain Operations - ICLT Program
Pharma ospi slides which help in ospi learning
Basic Mud Logging Guide for educational purpose
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
VCE English Exam - Section C Student Revision Booklet
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Ad

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.