SlideShare a Scribd company logo
Introduction to Python
What is Python ?
What you can do with it ?
Why it is so popular ?
Free and Open Source
High-level programming language
Free and Open Source
High-level, multi-purpose programming
language
Developed by Guido Van Rossum in the
late 1980s
Python is an interpreter-based
language
Portable, and Extensible
Python can be integrated with other popular programming
technologies like C, C++, Java, ActiveX, and CORBA.
Dynamic Typing
Supports procedural, object-oriented, & functional programming
What you can do with it ?
Desktop
Application
Desktop Application
Mobile Application
9
Why it is so popular ?
High-Level
Huge Community
Large Ecosystem
Platform-Independent
12
What can you do with Python
Develop web applications
Implementing machine learning algorithms such as Scikit-learn, NLTK
and Tensor flow .
Computer vision – Face detection , color detection while using OpenCV and python
Raspberry Pi – You can even build a robot and automate your home.
PyGame – Gaming applications
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
Is a reserved memory location to store
values
Variable Name
Every value in Python has
data type.
12
Computer memory
Age
0
Address
(index)
Data
Variables are used to store data, they take
memory space based on the type of value we
assigning to them.
Age = 12
16
Names cannot start with a number ,
No spaces in the names, use underscore _ instead
Special characters are not allowed as variable names
income@, <>, ?, ! , (), #,$ ,% , ^, &,*,~,- +
Variable Names and Naming rules
Variables in Python are case sensitive
It can only start with a character or an underscore
PythonStudyMaterialSTudyMaterial.pdf
20
Name Type Description
Integers int Whole numbers, such as 8 12 400
Floating Point float Numbers with a decimal point 3.3, 14.5, 500.0
Strings Str Ordered sequence of characters
“hello” , “Sammy”, “2000”, “*$LL”
Lists List Ordered sequence of objects [10, “hello world”, 112.4]
Dictionaries dict Unordered key:value pairs {“key”:”value”}
Tuples tup Ordered immutable sequence of objects (30,”Bye”, 111.32)
Sets Set Unordered collection of unique objects (10,20)
Booleans Bool Logical value indicating True or False
Data Types
type()
21
Type conversions
22
>>> float(22//5)
4.0
>>> int(4.5)
4
>>> int(3.9)
3
>>> round(3.9)
4
>>> round(3)
3
strings
23
String formatting
24
There are multiple ways to format strings for printing variables
in them
Myvar= “Hello”
Print(myvar + “World”)
This is knowns as string interpolation
String formatting
25
.fomat() method
Myvar= “Hello”
Print(myvar + “World”)
This is knowns as string interpolation
f-strings (formatted string literals)
String functions
26
index()
casefold()
center()
count()
endswith()
expandtabs()
isalnum()
isalpha()
isdecimal()
isidentifier()
islower()
str1.isnumeric()
str1.join()
Indexing and Slicing with Strings
27
Working with string data type
28
Booleans in Python
30
Booleans are two constant objects
It has only two possible values
Booleans are considered as numeric type in Python
Booleans
1. True
2. False
True == 1
False == 0
None as a Boolean value
Bool(None)
bool(3), bool(-3), bool(0) Nonzero integers are
truth
bool() method to convert a value to Boolean()
31
Boolean operators are those that take Boolean inputs and
return Boolean results
and operator can be defined in terms of ‘not’ and ‘or’
Boolean operators
Boolean operators are and , not, or
or operator can be defined in terms of ‘not’ and ‘and’
Conditional and control flow
Provides us with 3 types of control
statements
Conditional Programming
Used to control the order of execution of the program based on
the values and logic
continue
break
pass
34
expression: It’s the condition that needs to evaluated and
return a boolean (true/false)value.
statement: statement is a general python code that executes if
the expression returns true.
Control Structures
Loop Control Statements
36
Loops
Loop statements are used to execute the block of the code repeatedly for
a specified number of times
There are three types of loops
Python for loop
Python while loop
Python nested loop
38
while Loop
Syntax :
while test_expression:
#statement(s)
While loop will execute a block of statement as long as test expression is true
39
while ..else Loop
While loop will execute a block of statement as long as test expression is true
while test:
statements
if test: break # Exit loop now, skip else if present
if test: continue # Go to top of loop now, to test1
else:
statements # Run if we didn't hit a 'break'
40
continue statement
forces the loop to continue or execute the next iteration
When the continue statement is executed in the loop, the code inside the loop following
the continue statement will be skipped and the next iteration of the loop will begin.
41
break statement
The break statement causes an immediate exit from a loop
42
Nested for and while loops
Syntax : nested for loop
for <iterator_var1> in <iterable_object1>:
for <iterator_var2> in <iterable_object2>:
#statement(s)
#statement(s)
Loop statement inside another loop statement
Syntax : nested while loop
while <exp1>:
while<exp2>
#statement(s)
#statement(s)
43
break statement
The break statement causes an immediate exit from a loop
44
Nested for and while loops
Syntax : nested for loop
for <iterator_var1> in <iterable_object1>:
for <iterator_var2> in <iterable_object2>:
#statement(s)
#statement(s)
Loop statement inside another loop statement
Syntax : nested while loop
while <exp1>:
while<exp2>
#statement(s)
#statement(s)
Sets in Python
46
Sets
Identified by curly braces
-{‘Raja’,’Ashok’,’Alok’}
Sets do not support indexing
A set an unordered collection data type that
holds an unordered collection of unique elements
set is iterable , mutable and has no duplicate
47
Description Commands
Add item to set x x.add(item)
Remove an item x.remove(item)
get length of x len(x)
Check membership in x item in x
item not in x
Pop random item from set x x.pop()
Delete all items from x x.clear()
Basic Operations on Set
48
Basic Operations on Set
A set is a python data type that holds an unordered collection of unique elements
Identified by curly braces
-{‘Raja’,’Ashok’,’Alok’}
Can only contain unique elements
Duplicates are eliminated
Sets do not support indexing
49
Frozen sets
Frozen sets in Python are immutable
objects
50
Ranges
range is another kind of immutable sequence type
ranges are also called as generators
Note that the range includes the
lower bound and excludes the
upper bound.
If we pass a single parameter to the range function, it is used as the upper bound
If we use two parameters, the first is the lower bound and the second is the upper bound.
If we use three, the third parameter is the step size.
The default lower bound is zero, and the default step size is one
Sets, Loops , & Functions
in Python
Functions in Python
What is a function ?
Why use functions ?
Types of functions ?
Functions Vs Methods
Function Signatures - Parameter Vs Arguments
User-Defined functions
The return statement
How to call a function
How to add docstrings to a function
Function arguments in python
Global Vs Local Variables
Recursive & Anonymous functions
Using main() as a function
Function as an argument
Function as return value
Map and filter() function
inner function & Decorator
Positional Vs Keyword arguments
It’s a block of code using which you want to carry out a specific task repeatedly
A function may contain zero or more than one arguments
What are functions ?
Increases readability
Eliminate redundancy
Why to use functions ?
Reduces coupling
Built-in functions, such as help() to ask for help, min() to get the minimum value,
print() to print an object to the terminal
User-Defined Functions (UDFs), which are functions that users create to help them
out;
Types of functions
Anonymous functions, which are also called lambda functions because they are not
declared with the standard def keyword
How to define user-defined functions ?
Syntax
def functionName(<parameter list>):
statement 1
statement 2
…
return expression
is used to return a value from a function
def net_sal(basic, hra, loan):
keyword
return Nsal
Here, basic, hra, and loan are called parameters of net_sal()
Also note that, basic, hra, and loan are variables ,
local to my function net_sal()
59
How to call a function ?
def net_sal(basic, hra, loan):
Gsal = basic + hra
Calling a function is Python is similar to other programming languages
Also note that, basic, hra, and loan are variables ,
local to my function net_sal()
Nsal = Gsal - loan
return Nsal
net_sal(100000,22000,5000)
Syntax
function_name(arg1, arg2,arg3)
Here, basic, hra, and loan are the arguments of net_sal function
basic, hra, and loan are passed by reference
The memory addresses of basic, hra, and loan are passed
When we call the function
60
Positional arguments
def net_sal(basic, hra, loan):
# code here
Most common way of assigning arguments to parameters:
via the order in which they are passed
When we call the function
net_sal(basic,hra, loan)
basic = 132000
hra = 22000
loan = 5000
basic = 128000
hra = 21000
loan = 6000
Its positional arguments
61
Keyword arguments
def net_sal(basic, hra, loan):
# code here
When we call the function
net_sal(basic=132000,hra = 22000, loan = 5000)
basic = 132000
hra = 22000
loan = 5000
basic = 128000
hra = 21000
loan = 6000
Its keyword arguments
Once you have defined the keyword argument , you must specify the
Keyword for all the other arguments
net_sal(132000, hra=22000, 5000)
Keyword = value
Like positional args, the no. of args and parameters must still match
62
Keyword arguments
When we call the function
net_sal(132000,hra = 22000, loan = 5000)
net_sal(132000, 22000, loan = 5000) Its keyword arguments
Can I call a function using both positional and keyword arguments ??
net_sal(132000, hra=22000,
5000)
63
Default argument values
def net_sal(basic, hra=22000, loan=5000):
# code here
When we call the function
net_sal(132000)
net_sal(basic=132000,hra = 22000)
net_sal(hra=22000, basic=132000)
When you use keyword
Argument the order doesn’t matter
64
Arguments in summary
Positional arguments must agree in order and number with the parameters
declared in the function definition
Keyword arguments must agree with declared parameters in number, but they may be
specified in arbitrary order
Default parameters allow some arguments to be omitted when function is called
Ad

More Related Content

Similar to PythonStudyMaterialSTudyMaterial.pdf (20)

Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
Prerna Sharma
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
SahajShrimal1
 
1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics
hussainmuhd1119
 
Python
PythonPython
Python
Aashish Jain
 
03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
Pythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptxPythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
JNTUK python programming python unit 3.pptx
JNTUK python programming python unit 3.pptxJNTUK python programming python unit 3.pptx
JNTUK python programming python unit 3.pptx
Venkateswara Babu Ravipati
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.ppt
Rajasekhar364622
 
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
divijareddy0502
 
C463_02intoduction_to_python_to learnGAI.ppt
C463_02intoduction_to_python_to learnGAI.pptC463_02intoduction_to_python_to learnGAI.ppt
C463_02intoduction_to_python_to learnGAI.ppt
AhmedHamzaJandoubi
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Data Structure and Algorithms (DSA) with Python
Data Structure and Algorithms (DSA) with PythonData Structure and Algorithms (DSA) with Python
Data Structure and Algorithms (DSA) with Python
epsilonice
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
simenehanmut
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
Yusuf Ayuba
 
Functions2.pptx
Functions2.pptxFunctions2.pptx
Functions2.pptx
AkhilTyagi42
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
Karthik Prakash
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
Manzoor ALam
 
Lecture 08.pptx
Lecture 08.pptxLecture 08.pptx
Lecture 08.pptx
Mohammad Hassan
 
Functions_21_22.pdf
Functions_21_22.pdfFunctions_21_22.pdf
Functions_21_22.pdf
paijitk
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
Prerna Sharma
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
SahajShrimal1
 
1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics1P13 Python Review Session Covering various Topics
1P13 Python Review Session Covering various Topics
hussainmuhd1119
 
03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
Pythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptxPythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.ppt
Rajasekhar364622
 
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
divijareddy0502
 
C463_02intoduction_to_python_to learnGAI.ppt
C463_02intoduction_to_python_to learnGAI.pptC463_02intoduction_to_python_to learnGAI.ppt
C463_02intoduction_to_python_to learnGAI.ppt
AhmedHamzaJandoubi
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Data Structure and Algorithms (DSA) with Python
Data Structure and Algorithms (DSA) with PythonData Structure and Algorithms (DSA) with Python
Data Structure and Algorithms (DSA) with Python
epsilonice
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
simenehanmut
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
Yusuf Ayuba
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
Manzoor ALam
 
Functions_21_22.pdf
Functions_21_22.pdfFunctions_21_22.pdf
Functions_21_22.pdf
paijitk
 

Recently uploaded (20)

antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Ad

PythonStudyMaterialSTudyMaterial.pdf

  • 2. What is Python ? What you can do with it ? Why it is so popular ?
  • 3. Free and Open Source High-level programming language
  • 4. Free and Open Source High-level, multi-purpose programming language Developed by Guido Van Rossum in the late 1980s Python is an interpreter-based language
  • 5. Portable, and Extensible Python can be integrated with other popular programming technologies like C, C++, Java, ActiveX, and CORBA. Dynamic Typing Supports procedural, object-oriented, & functional programming
  • 6. What you can do with it ?
  • 9. 9
  • 10. Why it is so popular ?
  • 12. 12 What can you do with Python Develop web applications Implementing machine learning algorithms such as Scikit-learn, NLTK and Tensor flow . Computer vision – Face detection , color detection while using OpenCV and python Raspberry Pi – You can even build a robot and automate your home. PyGame – Gaming applications
  • 15. Is a reserved memory location to store values Variable Name Every value in Python has data type. 12 Computer memory Age 0 Address (index) Data Variables are used to store data, they take memory space based on the type of value we assigning to them. Age = 12
  • 16. 16 Names cannot start with a number , No spaces in the names, use underscore _ instead Special characters are not allowed as variable names income@, <>, ?, ! , (), #,$ ,% , ^, &,*,~,- + Variable Names and Naming rules Variables in Python are case sensitive It can only start with a character or an underscore
  • 18. 20 Name Type Description Integers int Whole numbers, such as 8 12 400 Floating Point float Numbers with a decimal point 3.3, 14.5, 500.0 Strings Str Ordered sequence of characters “hello” , “Sammy”, “2000”, “*$LL” Lists List Ordered sequence of objects [10, “hello world”, 112.4] Dictionaries dict Unordered key:value pairs {“key”:”value”} Tuples tup Ordered immutable sequence of objects (30,”Bye”, 111.32) Sets Set Unordered collection of unique objects (10,20) Booleans Bool Logical value indicating True or False Data Types
  • 20. Type conversions 22 >>> float(22//5) 4.0 >>> int(4.5) 4 >>> int(3.9) 3 >>> round(3.9) 4 >>> round(3) 3
  • 22. String formatting 24 There are multiple ways to format strings for printing variables in them Myvar= “Hello” Print(myvar + “World”) This is knowns as string interpolation
  • 23. String formatting 25 .fomat() method Myvar= “Hello” Print(myvar + “World”) This is knowns as string interpolation f-strings (formatted string literals)
  • 25. Indexing and Slicing with Strings 27
  • 26. Working with string data type 28
  • 28. 30 Booleans are two constant objects It has only two possible values Booleans are considered as numeric type in Python Booleans 1. True 2. False True == 1 False == 0 None as a Boolean value Bool(None) bool(3), bool(-3), bool(0) Nonzero integers are truth bool() method to convert a value to Boolean()
  • 29. 31 Boolean operators are those that take Boolean inputs and return Boolean results and operator can be defined in terms of ‘not’ and ‘or’ Boolean operators Boolean operators are and , not, or or operator can be defined in terms of ‘not’ and ‘and’
  • 31. Provides us with 3 types of control statements Conditional Programming Used to control the order of execution of the program based on the values and logic continue break pass
  • 32. 34 expression: It’s the condition that needs to evaluated and return a boolean (true/false)value. statement: statement is a general python code that executes if the expression returns true. Control Structures
  • 34. 36 Loops Loop statements are used to execute the block of the code repeatedly for a specified number of times There are three types of loops Python for loop Python while loop Python nested loop
  • 35. 38 while Loop Syntax : while test_expression: #statement(s) While loop will execute a block of statement as long as test expression is true
  • 36. 39 while ..else Loop While loop will execute a block of statement as long as test expression is true while test: statements if test: break # Exit loop now, skip else if present if test: continue # Go to top of loop now, to test1 else: statements # Run if we didn't hit a 'break'
  • 37. 40 continue statement forces the loop to continue or execute the next iteration When the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped and the next iteration of the loop will begin.
  • 38. 41 break statement The break statement causes an immediate exit from a loop
  • 39. 42 Nested for and while loops Syntax : nested for loop for <iterator_var1> in <iterable_object1>: for <iterator_var2> in <iterable_object2>: #statement(s) #statement(s) Loop statement inside another loop statement Syntax : nested while loop while <exp1>: while<exp2> #statement(s) #statement(s)
  • 40. 43 break statement The break statement causes an immediate exit from a loop
  • 41. 44 Nested for and while loops Syntax : nested for loop for <iterator_var1> in <iterable_object1>: for <iterator_var2> in <iterable_object2>: #statement(s) #statement(s) Loop statement inside another loop statement Syntax : nested while loop while <exp1>: while<exp2> #statement(s) #statement(s)
  • 43. 46 Sets Identified by curly braces -{‘Raja’,’Ashok’,’Alok’} Sets do not support indexing A set an unordered collection data type that holds an unordered collection of unique elements set is iterable , mutable and has no duplicate
  • 44. 47 Description Commands Add item to set x x.add(item) Remove an item x.remove(item) get length of x len(x) Check membership in x item in x item not in x Pop random item from set x x.pop() Delete all items from x x.clear() Basic Operations on Set
  • 45. 48 Basic Operations on Set A set is a python data type that holds an unordered collection of unique elements Identified by curly braces -{‘Raja’,’Ashok’,’Alok’} Can only contain unique elements Duplicates are eliminated Sets do not support indexing
  • 46. 49 Frozen sets Frozen sets in Python are immutable objects
  • 47. 50 Ranges range is another kind of immutable sequence type ranges are also called as generators Note that the range includes the lower bound and excludes the upper bound. If we pass a single parameter to the range function, it is used as the upper bound If we use two parameters, the first is the lower bound and the second is the upper bound. If we use three, the third parameter is the step size. The default lower bound is zero, and the default step size is one
  • 48. Sets, Loops , & Functions in Python
  • 50. What is a function ? Why use functions ? Types of functions ? Functions Vs Methods Function Signatures - Parameter Vs Arguments User-Defined functions The return statement How to call a function How to add docstrings to a function Function arguments in python Global Vs Local Variables Recursive & Anonymous functions Using main() as a function Function as an argument Function as return value Map and filter() function inner function & Decorator Positional Vs Keyword arguments
  • 51. It’s a block of code using which you want to carry out a specific task repeatedly A function may contain zero or more than one arguments What are functions ?
  • 52. Increases readability Eliminate redundancy Why to use functions ? Reduces coupling
  • 53. Built-in functions, such as help() to ask for help, min() to get the minimum value, print() to print an object to the terminal User-Defined Functions (UDFs), which are functions that users create to help them out; Types of functions Anonymous functions, which are also called lambda functions because they are not declared with the standard def keyword
  • 54. How to define user-defined functions ? Syntax def functionName(<parameter list>): statement 1 statement 2 … return expression is used to return a value from a function def net_sal(basic, hra, loan): keyword return Nsal Here, basic, hra, and loan are called parameters of net_sal() Also note that, basic, hra, and loan are variables , local to my function net_sal()
  • 55. 59 How to call a function ? def net_sal(basic, hra, loan): Gsal = basic + hra Calling a function is Python is similar to other programming languages Also note that, basic, hra, and loan are variables , local to my function net_sal() Nsal = Gsal - loan return Nsal net_sal(100000,22000,5000) Syntax function_name(arg1, arg2,arg3) Here, basic, hra, and loan are the arguments of net_sal function basic, hra, and loan are passed by reference The memory addresses of basic, hra, and loan are passed When we call the function
  • 56. 60 Positional arguments def net_sal(basic, hra, loan): # code here Most common way of assigning arguments to parameters: via the order in which they are passed When we call the function net_sal(basic,hra, loan) basic = 132000 hra = 22000 loan = 5000 basic = 128000 hra = 21000 loan = 6000 Its positional arguments
  • 57. 61 Keyword arguments def net_sal(basic, hra, loan): # code here When we call the function net_sal(basic=132000,hra = 22000, loan = 5000) basic = 132000 hra = 22000 loan = 5000 basic = 128000 hra = 21000 loan = 6000 Its keyword arguments Once you have defined the keyword argument , you must specify the Keyword for all the other arguments net_sal(132000, hra=22000, 5000) Keyword = value Like positional args, the no. of args and parameters must still match
  • 58. 62 Keyword arguments When we call the function net_sal(132000,hra = 22000, loan = 5000) net_sal(132000, 22000, loan = 5000) Its keyword arguments Can I call a function using both positional and keyword arguments ?? net_sal(132000, hra=22000, 5000)
  • 59. 63 Default argument values def net_sal(basic, hra=22000, loan=5000): # code here When we call the function net_sal(132000) net_sal(basic=132000,hra = 22000) net_sal(hra=22000, basic=132000) When you use keyword Argument the order doesn’t matter
  • 60. 64 Arguments in summary Positional arguments must agree in order and number with the parameters declared in the function definition Keyword arguments must agree with declared parameters in number, but they may be specified in arbitrary order Default parameters allow some arguments to be omitted when function is called
  翻译: