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

More Related Content

Similar to PythonStudyMaterialSTudyMaterial.pdf (20)

PPTX
python-presentationpython-presentationpython-presentation.pptx
rkameshwaran50
 
PDF
Introduction To Programming with Python
Sushant Mane
 
PPTX
python_computer engineering_semester_computer_language.pptx
MadhusmitaSahu40
 
PDF
Tutorial on-python-programming
Chetan Giridhar
 
PPTX
Dr.C S Prasanth-Physics ppt.pptx computer
kavitamittal18
 
PPTX
IoT-Week1-Day1-Lab.pptx
afsheenfaiq2
 
PDF
Python cheatsheat.pdf
HimoZZZ
 
PPTX
Q-SPractical_introduction_to_Python.pptx
JeromeTacata3
 
PPTX
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
nyomans1
 
PPT
Python tutorialfeb152012
Shani729
 
PPT
python language programming presentation
lbisht2
 
PPTX
Introduction to Basics of Python
Elewayte
 
PPTX
Programming Basics.pptx
mahendranaik18
 
PDF
Introduction to python
Mohammed Rafi
 
PPT
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
divijareddy0502
 
PPT
C463_02intoduction_to_python_to learnGAI.ppt
AhmedHamzaJandoubi
 
PPT
Phyton Learning extracts
Pavan Babu .G
 
PDF
Advanced Web Technology ass.pdf
simenehanmut
 
PPTX
scripting in Python
Team-VLSI-ITMU
 
python-presentationpython-presentationpython-presentation.pptx
rkameshwaran50
 
Introduction To Programming with Python
Sushant Mane
 
python_computer engineering_semester_computer_language.pptx
MadhusmitaSahu40
 
Tutorial on-python-programming
Chetan Giridhar
 
Dr.C S Prasanth-Physics ppt.pptx computer
kavitamittal18
 
IoT-Week1-Day1-Lab.pptx
afsheenfaiq2
 
Python cheatsheat.pdf
HimoZZZ
 
Q-SPractical_introduction_to_Python.pptx
JeromeTacata3
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
nyomans1
 
Python tutorialfeb152012
Shani729
 
python language programming presentation
lbisht2
 
Introduction to Basics of Python
Elewayte
 
Programming Basics.pptx
mahendranaik18
 
Introduction to python
Mohammed Rafi
 
C463_02_python.ppt,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
divijareddy0502
 
C463_02intoduction_to_python_to learnGAI.ppt
AhmedHamzaJandoubi
 
Phyton Learning extracts
Pavan Babu .G
 
Advanced Web Technology ass.pdf
simenehanmut
 
scripting in Python
Team-VLSI-ITMU
 

Recently uploaded (20)

PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Difference between write and update in odoo 18
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
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