4.Python Basics For Loops,Functions and Lambda

preview_player
Показать описание
Thanks for watching the video.

A loop is a used for iterating over a set of statements repeatedly. In Python we have three types of loops for, while and do-while.
for variable in sequence:

Here variable is a variable that is used for iterating over a sequence. On every iteration it takes the next value from sequence until the end of sequence is reached.

A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.

As you already know, Python gives you many built-in functions like print(), etc. but you can also create your own functions. These functions are called user-defined functions.

A lambda function is a small anonymous function.

A lambda function can take any number of arguments, but can only have one expression.

Why Use Lambda Functions?

The power of lambda is better shown when you use them as an anonymous function inside another function.

Say you have a function definition that takes one argument, and that argument will be multiplied with an unknown number:
Рекомендации по теме