SlideShare a Scribd company logo
“Lecture on Python”
by
Dr. Ravikiran A. Mundewadi
Assistant Professor
Department of Mathematics
M.E.S College of Arts, Commerce and Science,
Malleswaram, Bengaluru-03
An overview on python commands for solving the problems
Guido van Rossum
• Guido Van Rossum is a Dutch programmer best
known as the creator of the python programming
language. When he began implementing python,
Guido Van Rossum was also reading the
published scripts from “Monthly Phythan’s Flying
Circus, a BBC comedy series from the 1970’s.
• Van Rossum thought he needed a name that was
short, unique and slightly mysterious, so he
decided to call the language Phythan.
What is Python?
• Python is a high-level, general-purpose programming
language with an elegant syntax that allows programmers to
focus more on problem-solving than on syntax errors. One of
the primary goals of Python Developers is keeping it fun to
use. Python has become a big buzz in the field of
modern software development, infrastructure management,
and especially in Data Science and Artificial Intelligence.
Most recently, Python has risen to the top 3 list of
TIOBE index of language popularity.
• Python is becoming increasingly ubiquitous, but you must
be wondering why Python has become such a hot topic in the
developers’ world. In this tutorial, you will understand all
reasons behind Python’s popularity.
• It is often used as a “Scripting language ” for
web applications. This means that it can
automate specific serious of tasks, making it
more efficient. Consequently python is often
used in software applications, pages within
web browser, the shells of operating systems
and same games.
What is python mainly used for?
Why is python so popular?
• More productive. First and foremost reason
why python is so much popular is so much
popular because it is highly productive as
compare to other programming language like
C++ and JAVA, etc. Python is also very famous
for its simple programming syntax, code
readability and English like commands that
make coding in python lot easier and efficient.
www.python.org
Download for Windows
Step 1: Download Python 3.9.1
• To start, go to python.org/downloads and then click on the
button to download the latest version of Python:
Step 2: Run the .exe file
• Next, run the .exe file that you just
downloaded:
Step 3: Install Python 3.9.1
• You can now start the installation of Python by clicking
on Install Now:
An overview on python commands for solving the problems
An overview on python commands for solving the problems
IDLE: Integrated Development and
Learning Environment
OUTPUT: Immediate mode
• >>> indicates ‘Prompt’
Open the New File
INPUT: Script mode
• This is how the syntax would look like in the
“untitled” box:
• Press F5 on your keyboard. You will then get the
following message to save your code:
• Click on ‘OK’ to save the file
• Choose a location where the Python file will be
saved on your computer. You’ll also need to type
a name for your file. For example, type “Test” for
your file name:
Save the File Name
• It Save as “Test.py”
• “.py” indicates ‘Extension’
• Once you’re done, press Save, and you’ll then see the “Hello
World” expression printed on your Python Shell:
Python Shell:
• It gives the output as “Hello world”
INSTALLING PACKAGES FOR PYTHON
• 1. Go to search and type: cmd command
prompt or windows powershell is opened
• 2. Type: python -m pip install --upgrade pip
• 3. pip install numpy
• 4. pip install sympy
• 5. pip install matplotlib
• 6. pip install scipy
Command Prompt
Windows PowerShell
Pip Installation
An overview on python commands for solving the problems
An overview on python commands for solving the problems
What is PIP?
• PIP is a package manager for Python packages.
• Pip is one of the most famous and widely used
package management system to install and
manage software packages written in Python
and found in Python Package Index (PyPI). Pip
is a recursive acronym that can stand for
either "Pip Installs Packages" or "Pip Installs
Python". Alternatively, pip stands for
"preferred installer program".
Fundamentals of Python
Statements
• Python statements are nothing but logical
instructions that interpreter can read and
execute. It can be both single and multiline.
There are two categories of statements in
Python:
• Expression Statements
• Assignment Statements
Expression Statement
Assignment Statements
An overview on python commands for solving the problems
An overview on python commands for solving the problems
An overview on python commands for solving the problems
An overview on python commands for solving the problems
Indentation
Comments
An overview on python commands for solving the problems
Variables
An overview on python commands for solving the problems
Constants
Tokens
• Tokens are building blocks of a language. They
are the smallest individual unit of a program.
There are five types of tokens in Python.
Keywords
• Key words: Key words are pre defined words with special
meaning and these are reserved words must not be used as
normal identifier names. These key words consists of False,
True, None, and, or, not, as, is, in, if, elif, else, for, while,
assert, del, break, class, continue, def, except, global, finally,
from, import, lambda, non local, pass, return, try, with, yield.
Identifiers
• Identifiers are the names given to variables,
objects, classes, functions, lists and so on.
• Variables names must not be key words and
must not contain blank spaces.
• Variable names are made up of (A-Z, a-z, 0-9,
underscore_) and must not start with a digit.
Valied variables names are ABCD, abcd, AbCd,
A345, a_bG78, _product.
• Invalid variable names are 6ab, av fd, for, and.
Literals
String Literals:
A string literal is a sequence of characters surrounded by quotes. We
can use both single, double or triple quotes for a string. And, a
character literal is a single character surrounded by single or double
quotes.
Numeric Literals:
Numeric Literals are immutable (unchangeable). Numeric literals
can belong to 3 different numerical types Integer, Float, and
Complex.
Boolean Literals:
A Boolean literal can have any of the two values: True or False.
Collection literals:
There are four different literal collections List literals, Tuple literals,
Dict literals, and Set literals.
Special literals:
Python contains one special literal i.e. None. We use it to specify to
that field that is not created.
Punctuators or Separators
• ‘ indicates single quote
• “ indicates double quote
• # indicates for comment
•  indicates backslash
• ( ) indicates parentheses
• [ ] indicates square brackets
• { } indicates braces
• : indicates colon
• , indicates comma
Input and Output Statement
• Input statement : input() is used to input string, int(input()) is
used to input integer and float(input()) is used to input floating
value.
• Output statement:
• print statement :
• a=2
• b=3
• The print statement is a function its general form is
• Print(‘this is’,a,’that is’,b)
• Where a and b are pre assigned variable names. If the above
statement is executed the output will be as , this is 2 that is 3,
anything written between two single quotes or between two
double quotes are considered as string.
Lists, Tuple and Functions
Lists: Lists are defined as a= [ 1,2,3,4], indexing start
with 0 i.e. a[0]=1,a[1]=2,a[2[=3, a[3]=4. The elements
of the list may be any data type and are mutable.
Tuple : Tuples are the group of any data types separated
by commas and are enclosed in parenthesis.The
elements of tuple are immutable.
Example: a=(1,2,3), b=( ‘a’,2,”C”).
Functions : Functions are defined as
def name(arguments):
return expression
Example:
def f(x,y):
return x+y+2
Operators
Arithmetic Operators
Arithmetic Operators Operator Name Description Example
+ Addition Perform Addition
I=40, J=20
>>>I+ J
>>>60
- Subtraction Perform Subtraction
I=40, J=20
>>>I – J
>>>20
* Multiplication Perform Multiplication
I=40, J=20
>>>I * J
>>> 800
/ Division Perform Division
I=30, J=20
>>>I /J
>>> 2.5
% Modulus
Perform remainder after
Division
I=40, J=20
>>>I /J
>>> 0
** Exponent
Performs exponential
(power) calculation
I=4, J=20
>>>I /J
>>> 204
// Floor Division
Perform division
remove the decimal
value and return
Quotient value
I=30, J=20
>>>I//J
>>> 1
Assignment Operators
Operator Operator Name Description Example
= Assignment It assigns value from
right side operand to
left side operand
I = 40
It assigns 40 to I
+= Add then assign It performs addition
and then result is
assigned to left hand
operand
I+=J
that means I = I + J
-= Subtract then assign It performs
subtraction and then
result is assigned to
left hand operand
I-=J
that means I = I – J
*= Multiply the assign It performs
multiplication and
then result is assigned
to left hand operand.
I*=J
that means I = I * J
/= Divide then assign It performs division
and then result is
assigned to left hand
operand
I/=J
that means I = I / J
%= Modulus then assign It performs modulus
and then result is
assigned to left hand
operand
I%=J
that means I = I % J
**= Exponent then assign It performs exponent
and then result is
assigned to left hand
operand
I**=J
that means I = I ** J
//= Floor division then
assign
It performs floor
division and then
result is assigned to
left hand operand
I//=J
that means I = I // J
Comparison operator
Operator Operator Name Description Example
== Equal to If the values of two
operands are equal,
then it returns true.
I = 20, J = 20
(I == J) is True
!= Not Equal to If the values of two
operands are not
equal, then it returns
true.
I = 20, J = 20
(I != J) is False
< Less than If the value of left
operand is less than
the value of right
operand, then it
returns true
I = 40, J = 20
(I < J) is False
> Greater than If the value of left
operand is greater
than the value of right
operand, then it
returns true
I= 40, J = 20
(I > J) is True
<= Less than or equal to If the value of left
operand is less than or
equal to the value of
right operand, then it
returns true
I = 40, J = 20
(I <= J) is False
>= Greater than or equal
to
If the value of left
operand is greater
than or equal to the
value of right
operand, then it
returns true.
I = 40, J = 20
(I >= J) is True
<> Not equal to (similar
to !=)
If values of two
operands are not
equal, then condition
becomes true
I=40, J = 20
(I <> J) is True.
• Comparison operator is also known as
Relational Operators because it compares the
values. After comparison, it returns the
Boolean value i.e. either true or false.
Bitwise Operators
• It performs bit by bit operation.
Suppose there are two variables,
I = 10 and
J = 20
and their binary values are:
I = 10 = 0000 1010
J = 20 = 0001 0100
now let us see how bitwise operators perform.
Operator Operator Name Description Example
& Binary AND If both bits are 1 then
1 otherwise 0
I & J
0000 0000
| Binary OR If one of the bit is 1
then 1 otherwise 0
I | J
0001 1110
^ Binary XOR If both bit are same,
then 0 otherwise 1
I ^ J
0001 1110
~ Binary Complement If bit is 1 the make it
0 and if bit is 0 the
make it 1
~I
1111 0101
<< Binary Left Shift The left operands are
moved left by the
number of bits
specified by the right
operand.
I << 2
240 i.e. 1111 0000
>> Binary Right Shift The left operands are
moved right by the
number of bits
specified by the right
operand.
I >> 2
15 i.e. 1111
Membership Operators
Operator Description Example
in It returns true if it finds a
variable in the sequence
otherwise returns false
List = [1,2,3,4,5,6,7,8]
i=1
if i in List:
print(‘i is available in list’)
else:
print(‘i is not available in list’)
Output – i is available in list
not in It returns true if it does not
find a variable in the
sequence otherwise returns
false
List = [1,2,3,4,5,6,7,8]
j=10
if j not in List:
print (‘j is not available in list’)
else:
print (‘j is available in list’)
Output – j is not available in list
Identity Operators
• These operators are used to compare the
memory address of two objects.
Operator Description Example
is It returns true if both operand ‘s
identity is same otherwise false
I = 20
J = 20
if(I is J):
print (‘I and J have same identity’)
else:
print (‘I and J have not same identity’)
Output – I and J have same identity
is not It returns true if both operand ‘s
identity is not same otherwise
false
I = 20
J = 230
if(I is not J):
print (‘I and J have not same identity’)
else:
print (‘I and J have same identity’)
Output – I and J have not same identity
Logical Operators
Operator Operator Name Description Example
and Logical AND When Both side
condition is true the
result is true
otherwise false
2<1 and 2<3
False
or Logical OR When at least one
condition is true then
result is true
otherwise false
2<1 or 2<3
True
not Logical NOT Reverse the condition Not (5>4)
False
Python Conditional Statements
• if statement
• if else statement
• nested if statement
• for loop
• while loop
if statement
if else statement
nested if statement
for loop
The syntax of for loop is
for i in range(n):
S1
S2
S3
print()
First time i is initialized to zero and all the statements in the body of for loop(i.e.
S1,S2,S3) are executed once, then i increased by 1, again all the statements in the
body are executed, again i increased by 1 and the process continues ,when i reaches n
then the control comes out of for loop and the next statement (in this case it is the
print statement) is executed ( I takes the values from 0 to n-1).
for i in range(1,n):
S1
S2
S3
print()
In this case i start with 1and takes the values up to n-1.
for i in range(1,n,2):
S1
S2
S3
print()
In this case i start with 1 and takes the values less than n with increment 2.
while loop
The syntax of while loop is
while condition:
S1
S2
S3
print()
The while loop is executed as long as condition is true
if the condition is false then the control comes out of
the loop and the next statement is executed.
websites
• https://intellipaat.com/blog/tutorial/python-tutorial/
• https://www.codinground.com/tokens-python/
• https://datatofish.com/install-python/
• https://www.w3schools.com/python/default.asp
• https://realpython.com/
• https://www.programiz.com/python-programming/first-
program
• https://www.youtube.com/results?search_query=python
An overview on python commands for solving the problems
Ad

Recommended

Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
IruolagbePius
 
Python Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
yuvarajkumar334
 
Python basics
Python basics
Manisha Gholve
 
Python knowledge ,......................
Python knowledge ,......................
sabith777a
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
Learn about Python power point presentation
Learn about Python power point presentation
omsumukh85
 
Python
Python
Suman Chandra
 
Introduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx
MamtaKaundal1
 
Python Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
Python (3).pdf
Python (3).pdf
samiwaris2
 
Python Introduction
Python Introduction
vikram mahendra
 
How To Tame Python
How To Tame Python
Mohd Anwar Jamal Faiz
 
Python fundamentals
Python fundamentals
natnaelmamuye
 
Python Tutorial
Python Tutorial
AkramWaseem
 
Python tutorial
Python tutorial
Dominik KAszubowski
 
Python revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Intro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
Pyhton problem solving introduction and examples
Pyhton problem solving introduction and examples
ssuser65733f
 
Python-01| Fundamentals
Python-01| Fundamentals
Mohd Sajjad
 
Python-Basics.pptx
Python-Basics.pptx
TamalSengupta8
 
Python - Module 1.ppt
Python - Module 1.ppt
jaba kumar
 
Chapter1 python introduction syntax general
Chapter1 python introduction syntax general
ssuser77162c
 
Python quick guide
Python quick guide
Hasan Bisri
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 
unit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 

More Related Content

Similar to An overview on python commands for solving the problems (20)

Python
Python
Suman Chandra
 
Introduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx
MamtaKaundal1
 
Python Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
Python (3).pdf
Python (3).pdf
samiwaris2
 
Python Introduction
Python Introduction
vikram mahendra
 
How To Tame Python
How To Tame Python
Mohd Anwar Jamal Faiz
 
Python fundamentals
Python fundamentals
natnaelmamuye
 
Python Tutorial
Python Tutorial
AkramWaseem
 
Python tutorial
Python tutorial
Dominik KAszubowski
 
Python revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Intro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
Pyhton problem solving introduction and examples
Pyhton problem solving introduction and examples
ssuser65733f
 
Python-01| Fundamentals
Python-01| Fundamentals
Mohd Sajjad
 
Python-Basics.pptx
Python-Basics.pptx
TamalSengupta8
 
Python - Module 1.ppt
Python - Module 1.ppt
jaba kumar
 
Chapter1 python introduction syntax general
Chapter1 python introduction syntax general
ssuser77162c
 
Python quick guide
Python quick guide
Hasan Bisri
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 
unit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
Introduction to learn and Python Interpreter
Introduction to learn and Python Interpreter
Alamelu
 
11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx
MamtaKaundal1
 
Python Interview Questions PDF By ScholarHat.pdf
Python Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
Python (3).pdf
Python (3).pdf
samiwaris2
 
Intro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
Pyhton problem solving introduction and examples
Pyhton problem solving introduction and examples
ssuser65733f
 
Python-01| Fundamentals
Python-01| Fundamentals
Mohd Sajjad
 
Python - Module 1.ppt
Python - Module 1.ppt
jaba kumar
 
Chapter1 python introduction syntax general
Chapter1 python introduction syntax general
ssuser77162c
 
Python quick guide
Python quick guide
Hasan Bisri
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 

Recently uploaded (20)

Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
June 2025 Progress Update With Board Call_In process.pptx
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
Ad

An overview on python commands for solving the problems

  • 1. “Lecture on Python” by Dr. Ravikiran A. Mundewadi Assistant Professor Department of Mathematics M.E.S College of Arts, Commerce and Science, Malleswaram, Bengaluru-03
  • 4. • Guido Van Rossum is a Dutch programmer best known as the creator of the python programming language. When he began implementing python, Guido Van Rossum was also reading the published scripts from “Monthly Phythan’s Flying Circus, a BBC comedy series from the 1970’s. • Van Rossum thought he needed a name that was short, unique and slightly mysterious, so he decided to call the language Phythan.
  • 5. What is Python? • Python is a high-level, general-purpose programming language with an elegant syntax that allows programmers to focus more on problem-solving than on syntax errors. One of the primary goals of Python Developers is keeping it fun to use. Python has become a big buzz in the field of modern software development, infrastructure management, and especially in Data Science and Artificial Intelligence. Most recently, Python has risen to the top 3 list of TIOBE index of language popularity. • Python is becoming increasingly ubiquitous, but you must be wondering why Python has become such a hot topic in the developers’ world. In this tutorial, you will understand all reasons behind Python’s popularity.
  • 6. • It is often used as a “Scripting language ” for web applications. This means that it can automate specific serious of tasks, making it more efficient. Consequently python is often used in software applications, pages within web browser, the shells of operating systems and same games. What is python mainly used for?
  • 7. Why is python so popular? • More productive. First and foremost reason why python is so much popular is so much popular because it is highly productive as compare to other programming language like C++ and JAVA, etc. Python is also very famous for its simple programming syntax, code readability and English like commands that make coding in python lot easier and efficient.
  • 10. Step 1: Download Python 3.9.1 • To start, go to python.org/downloads and then click on the button to download the latest version of Python:
  • 11. Step 2: Run the .exe file • Next, run the .exe file that you just downloaded:
  • 12. Step 3: Install Python 3.9.1 • You can now start the installation of Python by clicking on Install Now:
  • 15. IDLE: Integrated Development and Learning Environment
  • 16. OUTPUT: Immediate mode • >>> indicates ‘Prompt’
  • 17. Open the New File
  • 19. • This is how the syntax would look like in the “untitled” box:
  • 20. • Press F5 on your keyboard. You will then get the following message to save your code: • Click on ‘OK’ to save the file • Choose a location where the Python file will be saved on your computer. You’ll also need to type a name for your file. For example, type “Test” for your file name:
  • 21. Save the File Name • It Save as “Test.py” • “.py” indicates ‘Extension’ • Once you’re done, press Save, and you’ll then see the “Hello World” expression printed on your Python Shell:
  • 22. Python Shell: • It gives the output as “Hello world”
  • 23. INSTALLING PACKAGES FOR PYTHON • 1. Go to search and type: cmd command prompt or windows powershell is opened • 2. Type: python -m pip install --upgrade pip • 3. pip install numpy • 4. pip install sympy • 5. pip install matplotlib • 6. pip install scipy
  • 29. What is PIP? • PIP is a package manager for Python packages. • Pip is one of the most famous and widely used package management system to install and manage software packages written in Python and found in Python Package Index (PyPI). Pip is a recursive acronym that can stand for either "Pip Installs Packages" or "Pip Installs Python". Alternatively, pip stands for "preferred installer program".
  • 31. Statements • Python statements are nothing but logical instructions that interpreter can read and execute. It can be both single and multiline. There are two categories of statements in Python: • Expression Statements • Assignment Statements
  • 44. Tokens • Tokens are building blocks of a language. They are the smallest individual unit of a program. There are five types of tokens in Python.
  • 45. Keywords • Key words: Key words are pre defined words with special meaning and these are reserved words must not be used as normal identifier names. These key words consists of False, True, None, and, or, not, as, is, in, if, elif, else, for, while, assert, del, break, class, continue, def, except, global, finally, from, import, lambda, non local, pass, return, try, with, yield.
  • 46. Identifiers • Identifiers are the names given to variables, objects, classes, functions, lists and so on. • Variables names must not be key words and must not contain blank spaces. • Variable names are made up of (A-Z, a-z, 0-9, underscore_) and must not start with a digit. Valied variables names are ABCD, abcd, AbCd, A345, a_bG78, _product. • Invalid variable names are 6ab, av fd, for, and.
  • 48. String Literals: A string literal is a sequence of characters surrounded by quotes. We can use both single, double or triple quotes for a string. And, a character literal is a single character surrounded by single or double quotes. Numeric Literals: Numeric Literals are immutable (unchangeable). Numeric literals can belong to 3 different numerical types Integer, Float, and Complex. Boolean Literals: A Boolean literal can have any of the two values: True or False. Collection literals: There are four different literal collections List literals, Tuple literals, Dict literals, and Set literals. Special literals: Python contains one special literal i.e. None. We use it to specify to that field that is not created.
  • 49. Punctuators or Separators • ‘ indicates single quote • “ indicates double quote • # indicates for comment • indicates backslash • ( ) indicates parentheses • [ ] indicates square brackets • { } indicates braces • : indicates colon • , indicates comma
  • 50. Input and Output Statement • Input statement : input() is used to input string, int(input()) is used to input integer and float(input()) is used to input floating value. • Output statement: • print statement : • a=2 • b=3 • The print statement is a function its general form is • Print(‘this is’,a,’that is’,b) • Where a and b are pre assigned variable names. If the above statement is executed the output will be as , this is 2 that is 3, anything written between two single quotes or between two double quotes are considered as string.
  • 51. Lists, Tuple and Functions Lists: Lists are defined as a= [ 1,2,3,4], indexing start with 0 i.e. a[0]=1,a[1]=2,a[2[=3, a[3]=4. The elements of the list may be any data type and are mutable. Tuple : Tuples are the group of any data types separated by commas and are enclosed in parenthesis.The elements of tuple are immutable. Example: a=(1,2,3), b=( ‘a’,2,”C”). Functions : Functions are defined as def name(arguments): return expression Example: def f(x,y): return x+y+2
  • 53. Arithmetic Operators Arithmetic Operators Operator Name Description Example + Addition Perform Addition I=40, J=20 >>>I+ J >>>60 - Subtraction Perform Subtraction I=40, J=20 >>>I – J >>>20 * Multiplication Perform Multiplication I=40, J=20 >>>I * J >>> 800 / Division Perform Division I=30, J=20 >>>I /J >>> 2.5 % Modulus Perform remainder after Division I=40, J=20 >>>I /J >>> 0 ** Exponent Performs exponential (power) calculation I=4, J=20 >>>I /J >>> 204 // Floor Division Perform division remove the decimal value and return Quotient value I=30, J=20 >>>I//J >>> 1
  • 54. Assignment Operators Operator Operator Name Description Example = Assignment It assigns value from right side operand to left side operand I = 40 It assigns 40 to I += Add then assign It performs addition and then result is assigned to left hand operand I+=J that means I = I + J -= Subtract then assign It performs subtraction and then result is assigned to left hand operand I-=J that means I = I – J *= Multiply the assign It performs multiplication and then result is assigned to left hand operand. I*=J that means I = I * J /= Divide then assign It performs division and then result is assigned to left hand operand I/=J that means I = I / J %= Modulus then assign It performs modulus and then result is assigned to left hand operand I%=J that means I = I % J **= Exponent then assign It performs exponent and then result is assigned to left hand operand I**=J that means I = I ** J //= Floor division then assign It performs floor division and then result is assigned to left hand operand I//=J that means I = I // J
  • 55. Comparison operator Operator Operator Name Description Example == Equal to If the values of two operands are equal, then it returns true. I = 20, J = 20 (I == J) is True != Not Equal to If the values of two operands are not equal, then it returns true. I = 20, J = 20 (I != J) is False < Less than If the value of left operand is less than the value of right operand, then it returns true I = 40, J = 20 (I < J) is False > Greater than If the value of left operand is greater than the value of right operand, then it returns true I= 40, J = 20 (I > J) is True <= Less than or equal to If the value of left operand is less than or equal to the value of right operand, then it returns true I = 40, J = 20 (I <= J) is False >= Greater than or equal to If the value of left operand is greater than or equal to the value of right operand, then it returns true. I = 40, J = 20 (I >= J) is True <> Not equal to (similar to !=) If values of two operands are not equal, then condition becomes true I=40, J = 20 (I <> J) is True.
  • 56. • Comparison operator is also known as Relational Operators because it compares the values. After comparison, it returns the Boolean value i.e. either true or false.
  • 57. Bitwise Operators • It performs bit by bit operation. Suppose there are two variables, I = 10 and J = 20 and their binary values are: I = 10 = 0000 1010 J = 20 = 0001 0100 now let us see how bitwise operators perform.
  • 58. Operator Operator Name Description Example & Binary AND If both bits are 1 then 1 otherwise 0 I & J 0000 0000 | Binary OR If one of the bit is 1 then 1 otherwise 0 I | J 0001 1110 ^ Binary XOR If both bit are same, then 0 otherwise 1 I ^ J 0001 1110 ~ Binary Complement If bit is 1 the make it 0 and if bit is 0 the make it 1 ~I 1111 0101 << Binary Left Shift The left operands are moved left by the number of bits specified by the right operand. I << 2 240 i.e. 1111 0000 >> Binary Right Shift The left operands are moved right by the number of bits specified by the right operand. I >> 2 15 i.e. 1111
  • 59. Membership Operators Operator Description Example in It returns true if it finds a variable in the sequence otherwise returns false List = [1,2,3,4,5,6,7,8] i=1 if i in List: print(‘i is available in list’) else: print(‘i is not available in list’) Output – i is available in list not in It returns true if it does not find a variable in the sequence otherwise returns false List = [1,2,3,4,5,6,7,8] j=10 if j not in List: print (‘j is not available in list’) else: print (‘j is available in list’) Output – j is not available in list
  • 60. Identity Operators • These operators are used to compare the memory address of two objects. Operator Description Example is It returns true if both operand ‘s identity is same otherwise false I = 20 J = 20 if(I is J): print (‘I and J have same identity’) else: print (‘I and J have not same identity’) Output – I and J have same identity is not It returns true if both operand ‘s identity is not same otherwise false I = 20 J = 230 if(I is not J): print (‘I and J have not same identity’) else: print (‘I and J have same identity’) Output – I and J have not same identity
  • 61. Logical Operators Operator Operator Name Description Example and Logical AND When Both side condition is true the result is true otherwise false 2<1 and 2<3 False or Logical OR When at least one condition is true then result is true otherwise false 2<1 or 2<3 True not Logical NOT Reverse the condition Not (5>4) False
  • 62. Python Conditional Statements • if statement • if else statement • nested if statement • for loop • while loop
  • 66. for loop The syntax of for loop is for i in range(n): S1 S2 S3 print() First time i is initialized to zero and all the statements in the body of for loop(i.e. S1,S2,S3) are executed once, then i increased by 1, again all the statements in the body are executed, again i increased by 1 and the process continues ,when i reaches n then the control comes out of for loop and the next statement (in this case it is the print statement) is executed ( I takes the values from 0 to n-1). for i in range(1,n): S1 S2 S3 print() In this case i start with 1and takes the values up to n-1. for i in range(1,n,2): S1 S2 S3 print() In this case i start with 1 and takes the values less than n with increment 2.
  • 67. while loop The syntax of while loop is while condition: S1 S2 S3 print() The while loop is executed as long as condition is true if the condition is false then the control comes out of the loop and the next statement is executed.
  • 68. websites • https://intellipaat.com/blog/tutorial/python-tutorial/ • https://www.codinground.com/tokens-python/ • https://datatofish.com/install-python/ • https://www.w3schools.com/python/default.asp • https://realpython.com/ • https://www.programiz.com/python-programming/first- program • https://www.youtube.com/results?search_query=python