Skip to main content

Featured

How to Open .emz File

EMZ Description: It is a Compresses Windows Enhance Metafile(EMZ), which are basically gzip compresses EMF file.This compressed file usually contains some type of graphics data. The EMZ format is most commonly used in Microsoft applications like Word, PowerPoint, and Visio. Way to open EMZ file: By Select file and Copy it. Open MS-Word and create a new Document. Paste your selected file, here. Your file displayed there as a picture. EMZ to other file formats: EMZ to JPEG: Right click on the picture and save as and select JPEG file formate and save. EMZ to PNG: Right click on the picture and  save as  and select  PNG  file formate and  save. EMZ to GIF: Right click on the picture and  save as  and select  GIF file formate and  save. EMZ to TIF: Right click on the picture and  save as  and select  TIF  file formate and  save. EMZ to BMP: Right click on the picture and...

Lambda Expression in Python.


Introducing Lambda Expression in Python:

  • Lambda is an Anonymous Function
  • Doesn't require a return anything.
  • Lambdas are single line function.
  • Can only be used as the subtitle for basic function.
  • Cannot a docstring.
  • Note that functions created with lambda expressions cannot contain statements or annotations.
The expression lambda arguments: expression yields a function object. The unnamed object behaves like a function object defined with:
def <lambda>(arguments)
                 return expression


Syntax for Lambda Expression:


 lambda arguments: expression


Example of Lambda and Function:


Aim: Write a Python Code for an addition of three numbers:

def addition(x,y,z):
    return x+y+z    #return addition of three numbers
print(addition(10,20,30))#gives you 60

Using Lambda Expression:

fun=lambda x,y,z:x+y+z """object_iterator_name=lambda arguments: expression"""
print(fun(12,10,20) #prints 42


Description:
In above programs our aim to an addition of the three numbers, so we can do it through many ways. In the second example, fun is the object name of lambda as others are in python and after assignment operator(=) starts with lambda keyword and put arguments as we define in function arguments after it.After put ":" (symbol) can identify python that arguments are ended and expression part become start and put expression after this symbol(":").

Few More Example of Lambda Expression in Python:


  • Lambda Expression in Python good for,


>>> sorted(range(-5, 6), formula=lambda x: x ** 2)

[0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5]
  • Lambda Expression in Python where might not be work properly because of makes some bugs,

>>> class Car:...     lever = lambda self: print('Wroom!')...     crashing = lambda self: print('Boom!')>>> my_car = Car()>>> my_car.crashing()'Boom!'

Comments

Popular Posts