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
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:
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
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
Indentation
Comments
Variables
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

More Related Content

Similar to An overview on python commands for solving the problems

How To Tame Python
How To Tame PythonHow To Tame Python
How To Tame Python
Mohd Anwar Jamal Faiz
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
natnaelmamuye
 
Python Tutorial
Python TutorialPython Tutorial
Python Tutorial
AkramWaseem
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
Dominik KAszubowski
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
Mohd Sajjad
 
Python-Basics.pptx
Python-Basics.pptxPython-Basics.pptx
Python-Basics.pptx
TamalSengupta8
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
jaba kumar
 
Python quick guide
Python quick guidePython 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...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.pptxunit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
Unit -1 CAP.pptx
Unit -1 CAP.pptxUnit -1 CAP.pptx
Unit -1 CAP.pptx
malekaanjum1
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
deepak teja
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
Elaf A.Saeed
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
alaparthi
 
Get started python programming part 1
Get started python programming   part 1Get started python programming   part 1
Get started python programming part 1
Nicholas I
 
modul-python-part1.pptx
modul-python-part1.pptxmodul-python-part1.pptx
modul-python-part1.pptx
Yusuf Ayuba
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
ZENUS INFOTECH INDIA PVT. LTD.
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 

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

How To Tame Python
How To Tame PythonHow To Tame Python
How To Tame Python
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Python Tutorial
Python TutorialPython Tutorial
Python Tutorial
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Python-Basics.pptx
Python-Basics.pptxPython-Basics.pptx
Python-Basics.pptx
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
 
Python quick guide
Python quick guidePython quick guide
Python quick guide
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Unit -1 CAP.pptx
Unit -1 CAP.pptxUnit -1 CAP.pptx
Unit -1 CAP.pptx
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
 
Get started python programming part 1
Get started python programming   part 1Get started python programming   part 1
Get started python programming part 1
 
modul-python-part1.pptx
modul-python-part1.pptxmodul-python-part1.pptx
modul-python-part1.pptx
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
 

Recently uploaded

বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 

Recently uploaded (20)

বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 

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
  • 2.
  • 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:
  • 13.
  • 14.
  • 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
  • 27.
  • 28.
  • 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
  • 34.
  • 35.
  • 36.
  • 37.
  • 40.
  • 42.
  • 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