SlideShare a Scribd company logo
1 of 8
Lambda and Import
‫إعداد‬:
‫م‬.‫محمد‬ ‫علي‬
objectives
 Lambda function
 Using Import keyword in Python
Lambda Function
 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
Lambda Function
 Example:
x = lambda a : a + 10
print(x(5))
 Result
15
Lambda Function
 Example:
x = lambda a : a * 10
print(x(10))
 Result
100
 Example
x = lambda a, b : a * b
print(x(5, 6))
 Result
30
Why Use Lambda Functions?
 The power of lambda is better shown when you use them as an
anonymous function inside another function.
 Say We have a function definition that takes one argument, and that
argument will be multiplied with an unknown number
def myfunc(n):
return lambda a : a * n
mydoubler = myfunc(2)
print(mydoubler(11))
Result: 22
Import in python
 We use import keyword to import libraries to our code
 Syntax
import library_name;
 We can use one method from library using from keyword
from library import method1
 We can use a shortcuts for library to short it’s name
import library as lib
 If some library has many method we need we can use (*) to import all of it
from library import *
Import in python example
 Import os
 import matplotlib.pyplot as pit
 from sklearn import datasets
 from cryptography.fernet import *

More Related Content

What's hot

Inline function
Inline functionInline function
Inline function
Tech_MX
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
Charndeep Sekhon
 
C++ Function
C++ FunctionC++ Function
C++ Function
Hajar
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
abhay singh
 

What's hot (20)

FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programming
 
First approach in linq
First approach in linqFirst approach in linq
First approach in linq
 
Inline function
Inline functionInline function
Inline function
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)
 
C++ overloading
C++ overloadingC++ overloading
C++ overloading
 
Daa
DaaDaa
Daa
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
 

Similar to Ninth session

Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Jaliya Udagedara
 

Similar to Ninth session (20)

Python lambda.pptx
Python lambda.pptxPython lambda.pptx
Python lambda.pptx
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
 
functions.pptx
functions.pptxfunctions.pptx
functions.pptx
 
C#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-ExpressionC#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-Expression
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Chapter - 4.pptx
Chapter - 4.pptxChapter - 4.pptx
Chapter - 4.pptx
 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
 
Lambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream APILambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream API
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Working with functions in matlab
Working with functions in matlabWorking with functions in matlab
Working with functions in matlab
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
Fun with lambda expressions
Fun with lambda expressionsFun with lambda expressions
Fun with lambda expressions
 
tutorials-c-sharp_understanding-generic-anonymous-methods-and-lambda-expressi...
tutorials-c-sharp_understanding-generic-anonymous-methods-and-lambda-expressi...tutorials-c-sharp_understanding-generic-anonymous-methods-and-lambda-expressi...
tutorials-c-sharp_understanding-generic-anonymous-methods-and-lambda-expressi...
 
Fun with lambda expressions
Fun with lambda expressionsFun with lambda expressions
Fun with lambda expressions
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
"Capture" in lambda expression.
"Capture" in lambda expression."Capture" in lambda expression.
"Capture" in lambda expression.
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 

More from AliMohammad155

More from AliMohammad155 (20)

#1 الدرس الأول من دروس مسار تعلم ال SQL Server بعنوان مخطط ال ERD والتكامل ا...
#1  الدرس الأول من دروس مسار تعلم ال SQL Server بعنوان مخطط ال ERD والتكامل ا...#1  الدرس الأول من دروس مسار تعلم ال SQL Server بعنوان مخطط ال ERD والتكامل ا...
#1 الدرس الأول من دروس مسار تعلم ال SQL Server بعنوان مخطط ال ERD والتكامل ا...
 
شرح مبسط وبسيط لمفهوم ال VLAN
شرح مبسط وبسيط لمفهوم ال VLANشرح مبسط وبسيط لمفهوم ال VLAN
شرح مبسط وبسيط لمفهوم ال VLAN
 
11th session classes diagrams
11th session classes diagrams11th session classes diagrams
11th session classes diagrams
 
10th session erd
10th session erd10th session erd
10th session erd
 
Static route and rip and ospf
Static route and rip and ospfStatic route and rip and ospf
Static route and rip and ospf
 
Ninth session software engineering sequence diagram
Ninth session software engineering sequence diagramNinth session software engineering sequence diagram
Ninth session software engineering sequence diagram
 
Routers and packet tracer
Routers and packet tracerRouters and packet tracer
Routers and packet tracer
 
Viii session activity diagram
Viii session activity diagramViii session activity diagram
Viii session activity diagram
 
OSI Model
OSI ModelOSI Model
OSI Model
 
Seventh session functional and non functional requrements & usecase example
Seventh session functional and non functional requrements & usecase exampleSeventh session functional and non functional requrements & usecase example
Seventh session functional and non functional requrements & usecase example
 
Vlsm and flsm example
Vlsm and flsm exampleVlsm and flsm example
Vlsm and flsm example
 
Sixth session software engineering usecase diagrams
Sixth session software engineering usecase diagramsSixth session software engineering usecase diagrams
Sixth session software engineering usecase diagrams
 
fifth session in networking subnetmask and subnetting
fifth session in networking subnetmask and subnettingfifth session in networking subnetmask and subnetting
fifth session in networking subnetmask and subnetting
 
functional requirements and non functional requirements
functional requirements and non functional requirementsfunctional requirements and non functional requirements
functional requirements and non functional requirements
 
fourth session of basics in networks
fourth session of basics in networksfourth session of basics in networks
fourth session of basics in networks
 
Fourth session software engineering
Fourth session software engineeringFourth session software engineering
Fourth session software engineering
 
third session of basics in networks
third session of basics in networksthird session of basics in networks
third session of basics in networks
 
Third session software engineering
Third session software engineeringThird session software engineering
Third session software engineering
 
Second session Networking (Network topology)
Second session Networking (Network topology)Second session Networking (Network topology)
Second session Networking (Network topology)
 
Second session software engineering algorithms
Second session software engineering   algorithmsSecond session software engineering   algorithms
Second session software engineering algorithms
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Ninth session

  • 2. objectives  Lambda function  Using Import keyword in Python
  • 3. Lambda Function  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
  • 4. Lambda Function  Example: x = lambda a : a + 10 print(x(5))  Result 15
  • 5. Lambda Function  Example: x = lambda a : a * 10 print(x(10))  Result 100  Example x = lambda a, b : a * b print(x(5, 6))  Result 30
  • 6. Why Use Lambda Functions?  The power of lambda is better shown when you use them as an anonymous function inside another function.  Say We have a function definition that takes one argument, and that argument will be multiplied with an unknown number def myfunc(n): return lambda a : a * n mydoubler = myfunc(2) print(mydoubler(11)) Result: 22
  • 7. Import in python  We use import keyword to import libraries to our code  Syntax import library_name;  We can use one method from library using from keyword from library import method1  We can use a shortcuts for library to short it’s name import library as lib  If some library has many method we need we can use (*) to import all of it from library import *
  • 8. Import in python example  Import os  import matplotlib.pyplot as pit  from sklearn import datasets  from cryptography.fernet import *