SlideShare a Scribd company logo
1 of 47
MODULE 2
IF
• Python supports the usual logical conditions from
mathematics:
• Equals: a == b
• Not Equals: a != b
• Less than: a < b
• Less than or equal to: a <= b
• Greater than: a > b
• Greater than or equal to: a >= b
• These conditions can be used in several ways, most
commonly in "if statements" and loops.
• An "if statement" is written by using the if keyword.
EXAMPLE
a = 33
b = 200
if b > a:
print("b is greater than a")
0UTPUT
b is greater than a
EXAMPLE
• a = 33
b = 200
if b > a:
print("b is greater than a")
• # you will get an error
Elif
• The elif keyword is pythons way of saying "if the previous conditions
were not true, then try this condition".
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
• In this example a is equal to b, so the first condition is not true, but
the elif condition is true, so we print to screen that "a and b are
equal".
Else
• The else keyword catches anything which isn't caught by the
PREVIOUS conditions.
• a = 200
• b = 33
• if b > a:
• print("b is greater than a")
• elif a == b:
• print("a and b are equal")
• else:
• print("a is greater than b")
In this example a is greater than b, so the first condition is not
true,
also the elif condition is not true,

so we go to the else condition and print to screen that "a is
greater than b".
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
You can also have an else without the elif:
• You can have if statements inside if statements, this is
called nested if statements.
• x = 41
• if x > 10:
• print("Above ten,")
• if x > 20:
• print("and also above 20!")
• else:
• print("but not above 20.")
Nested If
.
Python Loops
• Python has two loop commands:
•while loops
•for loops
The while Loop
• With the while loop we can execute a set of statements as long as a condition is
true.
• Example
• Print i as long as i is less than 6:
• i = 1
• while i < 6:
• print(i)
• i += 1
The break Statement
• With the break statement we can stop the loop even if the while condition is true:
• Example
• Exit the loop when i is 3:
• i = 1
• while i < 6:
• print(i)
• if i == 3:
• break
• i += 1
The continue Statement
• With the continue statement we can stop the current iteration, and continue with the
next:
• Example
• Continue to the next iteration if i is 3:
• i = 0
• while i < 6:
• i += 1
• if i == 3:
• continue
• print(i) op; 1 2 4 5 6: 3 is missing
Python For Loops
• A for loop is used for repeating over a sequence (that is either a list, a
tuple, a dictionary, a set, or a string).
• With the for loop we can execute a set of statements, once for each item
in a list, tuple, set etc.
Example
• Print each fruit in a fruit list:
• fruits = ["apple", "banana", "cherry"]
• for x in fruits:
• print(x)
Example
• Loop through the letters in the word "banana":
• for x in "banana":
print(x)
The pass Statement
• if statements cannot be empty, but if you for some reason have an if statement
with no content:
put in the pass statement to avoid getting an error.
Example
• a = 33
• b = 200
• if b > a:
• pass
• # having an empty if statement like this, would raise an error without the pass
statement
Nested for
• A nested loop is a loop inside a loop.
• Example
• Print each adjective for every fruit:
• adj = ["red", "big", "tasty"]
• fruits = ["apple", "banana", "cherry"]
• for x in adj:
• for y in fruits:
• print(x, y)
Function
• A function is a block of code which only runs when it is
called.
• You can pass data, known as parameters, into a function.
• A function can return data as a result.
Advantage of Function
• Reducing the duplication of code
• Improved reusability of code
• Clearer code.
• Bigger problems are broken down into smaller problems
Creating a Function
• In Python a function is defined using the def keyword:
• Example
• def my_function():
•
print("Hello from a function")
Calling a Function
• To call a function, use the function name followed by
parenthesis:
• Example
• def my_function():
print("Hello from a function")
my_function()
Python Return
• The Python return statement is used to return a value from a function.
• The user can only use the return statement in a function.
• It cannot be used outside of the Python function. A return statement includes the
return keyword and the value that will be returned after that.
• Syntax of return statement:
• def funtion_name():
• statements
• .
• .
• .
• return [expression]
Example
Arguments
• Information can be passed into functions as arguments.
• Arguments are specified after the function name, inside the
parentheses. You can add as many arguments as you want, just
separate them with a comma.
• The following example has a function with one argument
(fname). When the function is called, we pass along a first
name, which is used inside the function to print the full name:
Number of Arguments
• By default, a function must be called with the correct number
of arguments.
• Meaning that if your function expects 2 arguments, you have
to call the function with 2 arguments, not more, and not less.
Passing a List as an Argument
• You can send any data types of argument to a function
(string, number, list, dictionary etc.),
• and it will be treated as the same data type inside the
function.
Return Values
To let a function return a value, use the return statement:
The pass Statement
• function definitions cannot be empty, but if you for some reason have a
function definition with no content, put in the pass statement to avoid
getting an error.
• The pass Statement
Python Lambda
• A lambda function is a small anonymous function.
• A lambda function can take any number of arguments, but can
only have one expression.
• Syntax
• lambda arguments : expression
• The expression is executed and the result is returned:
built-in python functions
• Built-in functions are ones for which the compiler generates
inline code at compile time.
• There are 68 built-in python functions.
Map function
• The map() function applies a given function to each item of an
iterable (list, tuple etc.) and returns an iterator.
Filter Function
• The filter() function extracts elements from an iterable (list, tuple etc.)
for which a function returns True.
module 2.pptx

More Related Content

Similar to module 2.pptx

Python unit 2 M.sc cs
Python unit 2 M.sc csPython unit 2 M.sc cs
Python unit 2 M.sc csKALAISELVI P
 
powerpoint 2-7.pptx
powerpoint 2-7.pptxpowerpoint 2-7.pptx
powerpoint 2-7.pptxJuanPicasso7
 
IoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptxIoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptxafsheenfaiq2
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
 
Exception handling and function in python
Exception handling and function in pythonException handling and function in python
Exception handling and function in pythonTMARAGATHAM
 
Building arcade game using python workshop
 Building arcade game using python workshop Building arcade game using python workshop
Building arcade game using python workshopGDGKuwaitGoogleDevel
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBrixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBasil Bibi
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methodsPranavSB
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & LoopsAkhil Kaushik
 

Similar to module 2.pptx (20)

Python
PythonPython
Python
 
Python unit 2 M.sc cs
Python unit 2 M.sc csPython unit 2 M.sc cs
Python unit 2 M.sc cs
 
powerpoint 2-7.pptx
powerpoint 2-7.pptxpowerpoint 2-7.pptx
powerpoint 2-7.pptx
 
IoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptxIoT-Week1-Day1-Lab.pptx
IoT-Week1-Day1-Lab.pptx
 
com.pptx
com.pptxcom.pptx
com.pptx
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
python ppt.pptx
python ppt.pptxpython ppt.pptx
python ppt.pptx
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
 
Exception handling and function in python
Exception handling and function in pythonException handling and function in python
Exception handling and function in python
 
UNIT 3 python.pptx
UNIT 3 python.pptxUNIT 3 python.pptx
UNIT 3 python.pptx
 
Building arcade game using python workshop
 Building arcade game using python workshop Building arcade game using python workshop
Building arcade game using python workshop
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 RecapBrixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 Recap
 
kotlin-nutshell.pptx
kotlin-nutshell.pptxkotlin-nutshell.pptx
kotlin-nutshell.pptx
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Vba Class Level 1
Vba Class Level 1Vba Class Level 1
Vba Class Level 1
 
Python Loop
Python LoopPython Loop
Python Loop
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 

Recently uploaded

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 

Recently uploaded (20)

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 

module 2.pptx

  • 2. IF • Python supports the usual logical conditions from mathematics: • Equals: a == b • Not Equals: a != b • Less than: a < b • Less than or equal to: a <= b • Greater than: a > b • Greater than or equal to: a >= b • These conditions can be used in several ways, most commonly in "if statements" and loops. • An "if statement" is written by using the if keyword.
  • 3. EXAMPLE a = 33 b = 200 if b > a: print("b is greater than a") 0UTPUT b is greater than a
  • 4. EXAMPLE • a = 33 b = 200 if b > a: print("b is greater than a") • # you will get an error
  • 5. Elif • The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition". a = 33 b = 33 if b > a: print("b is greater than a") elif a == b: print("a and b are equal") • In this example a is equal to b, so the first condition is not true, but the elif condition is true, so we print to screen that "a and b are equal".
  • 6. Else • The else keyword catches anything which isn't caught by the PREVIOUS conditions. • a = 200 • b = 33 • if b > a: • print("b is greater than a") • elif a == b: • print("a and b are equal") • else: • print("a is greater than b")
  • 7. In this example a is greater than b, so the first condition is not true, also the elif condition is not true, so we go to the else condition and print to screen that "a is greater than b".
  • 8. a = 200 b = 33 if b > a: print("b is greater than a") else: print("b is not greater than a") You can also have an else without the elif:
  • 9. • You can have if statements inside if statements, this is called nested if statements. • x = 41 • if x > 10: • print("Above ten,") • if x > 20: • print("and also above 20!") • else: • print("but not above 20.") Nested If .
  • 10. Python Loops • Python has two loop commands: •while loops •for loops
  • 11. The while Loop • With the while loop we can execute a set of statements as long as a condition is true. • Example • Print i as long as i is less than 6: • i = 1 • while i < 6: • print(i) • i += 1
  • 12. The break Statement • With the break statement we can stop the loop even if the while condition is true: • Example • Exit the loop when i is 3: • i = 1 • while i < 6: • print(i) • if i == 3: • break • i += 1
  • 13. The continue Statement • With the continue statement we can stop the current iteration, and continue with the next: • Example • Continue to the next iteration if i is 3: • i = 0 • while i < 6: • i += 1 • if i == 3: • continue • print(i) op; 1 2 4 5 6: 3 is missing
  • 14. Python For Loops • A for loop is used for repeating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). • With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
  • 15. Example • Print each fruit in a fruit list: • fruits = ["apple", "banana", "cherry"] • for x in fruits: • print(x)
  • 16. Example • Loop through the letters in the word "banana": • for x in "banana": print(x)
  • 17. The pass Statement • if statements cannot be empty, but if you for some reason have an if statement with no content: put in the pass statement to avoid getting an error. Example • a = 33 • b = 200 • if b > a: • pass • # having an empty if statement like this, would raise an error without the pass statement
  • 18. Nested for • A nested loop is a loop inside a loop. • Example • Print each adjective for every fruit: • adj = ["red", "big", "tasty"] • fruits = ["apple", "banana", "cherry"] • for x in adj: • for y in fruits: • print(x, y)
  • 19.
  • 20. Function • A function is a block of code which only runs when it is called. • You can pass data, known as parameters, into a function. • A function can return data as a result.
  • 21. Advantage of Function • Reducing the duplication of code • Improved reusability of code • Clearer code. • Bigger problems are broken down into smaller problems
  • 22. Creating a Function • In Python a function is defined using the def keyword: • Example • def my_function(): • print("Hello from a function")
  • 23. Calling a Function • To call a function, use the function name followed by parenthesis: • Example • def my_function(): print("Hello from a function") my_function()
  • 24.
  • 25. Python Return • The Python return statement is used to return a value from a function. • The user can only use the return statement in a function. • It cannot be used outside of the Python function. A return statement includes the return keyword and the value that will be returned after that. • Syntax of return statement: • def funtion_name(): • statements • . • . • . • return [expression]
  • 27.
  • 28. Arguments • Information can be passed into functions as arguments. • Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma. • The following example has a function with one argument (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name:
  • 29.
  • 30. Number of Arguments • By default, a function must be called with the correct number of arguments. • Meaning that if your function expects 2 arguments, you have to call the function with 2 arguments, not more, and not less.
  • 31.
  • 32. Passing a List as an Argument • You can send any data types of argument to a function (string, number, list, dictionary etc.), • and it will be treated as the same data type inside the function.
  • 33.
  • 34.
  • 35.
  • 36. Return Values To let a function return a value, use the return statement:
  • 37.
  • 38. The pass Statement • function definitions cannot be empty, but if you for some reason have a function definition with no content, put in the pass statement to avoid getting an error. • The pass Statement
  • 39. Python Lambda • A lambda function is a small anonymous function. • A lambda function can take any number of arguments, but can only have one expression. • Syntax • lambda arguments : expression • The expression is executed and the result is returned:
  • 40.
  • 41.
  • 42. built-in python functions • Built-in functions are ones for which the compiler generates inline code at compile time. • There are 68 built-in python functions.
  • 43.
  • 44. Map function • The map() function applies a given function to each item of an iterable (list, tuple etc.) and returns an iterator.
  • 45.
  • 46. Filter Function • The filter() function extracts elements from an iterable (list, tuple etc.) for which a function returns True.