What is a Lambda form? Explain about assert statement?



What is a Lambda form? Explain about assert statement?..

Answer / chaitanya

The lambda form:

Using lambda keyword tiny anonymous functions can be created.

It is a very powerful feature of Python which declares a one-line unknown small function on the fly. The lambda is used to create new function objects and then return them at runtime.

The general format for lambda form is:

lambda parameter(s): expression using the parameter(s)

For instance k is lambda function-

>>> k= lambda y: y + y

>>> k(30)

60

>>> k(40)

80

The assert statement:

The build-in assert statement of python introduced in version 1.5 is used to assert that something is true.

Programmers often place assertions at the beginning of a function to check for valid input, and after function call to check for valid output. Assert statement can be removed after testing of program is over.

If assert evaluates to be false, an AssertionError exception is raised. AssertionError exceptions can be handled with the try-except statement.

The general syntax for assert statement is:

assert Expression[, Arguments]

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

What are the 5 tuples?

0 Answers  


How would you perform unit-testing on your python code?

0 Answers  


What is map?

0 Answers  


Why to use python numpy instead o f lists?

0 Answers  


Is compiled python faster?

0 Answers  






1) How to validate ip address using regex 2)program to increment ip address in python Please find answers to above questions thanks in advance.

0 Answers  


Does python have private methods?

0 Answers  


What is python, what are the benefits of using it, and what do you understand of pep 8?

0 Answers  


What is a floating point in python?

0 Answers  


Describe about the libraries of python?

0 Answers  


What is memory management in python?

0 Answers  


What does it mean if something is static?

0 Answers  


Categories