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

List of lists changes reflected across sublists unexpectedly?

0 Answers  


Explain how to create a multidimensional list.

1 Answers  


What is import time in python?

0 Answers  


Can python make websites?

0 Answers  


Is python good for web development?

0 Answers  


How do you protect python source code?

0 Answers  


How to install python and prepare environment?

0 Answers  


What is the mro in python?

0 Answers  


What types are iterable in python?

0 Answers  


Which oops talks about data hiding?

0 Answers  


What is sys stdout flush ()?

0 Answers  


We know python is all the rage these days. But to be truly accepting of a great technology, you must know its pitfalls as well. Would you like to talk about this?

0 Answers  


Categories