Free Python Course
Kanalga Telegram’da o‘tish
Ko'proq ko'rsatish
5 967
Obunachilar
Ma'lumot yo'q24 soatlar
-357 kun
-22530 kun
Postlar arxiv
5 967
ANY FUNCTION
Any Returns true if any of the items is True. It returns False if empty or all are false. Any can be thought of as a sequence of OR operations on the provided iterables. It short circuit the execution i.e. stop the execution as soon as the result is known.
5 967
ZIP FUNCTION EXAMPLE 2
list_1 = ['User','Age','Salary']
list_2 = ['Rushi',19,28000] Converting Zip into a List
data_return =
list(zip(list_1,list_2)) print(data_return)5 967
ZIP FUNCTION EXAMPLE 1
list_1 = ['User','Age','Salary']
list_2 = ['Rushi',19,28000]
data_return = zip(list_1,list_2)
print(data_return)
Output
<zip object at 0x0000008C0C985080>5 967
ZIP FUNCTION
The zip() function returns a zip object, which is an iterator of tuples where the first item in each passed iterator is paired together, and then the second item in each passed iterator are paired together etc. If the passed iterators have different lengths, the iterator with the least items decides the length of the new iterator.
5 967
MAP FUNCTION EXAMPLE
def addition(n) :
return n + n
numbers = (1, 2, 3, 4)
result = map(addition, numbers)
print(list(result))
Output
[2, 4, 6, 8]5 967
fun : It is a function to which map passes each element of given iterable.
iter : It is a iterable which is to be mapped.
NOTE : You can pass one or more iterable to the map() function.
5 967
MAP FUNCTION
map() function returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable (list, tuple etc.)
5 967
WHY USE LAMBDA FUNCTION ?
You should use the lambda function to create simple expressions. For example, expressions that do not include complex structures such as if-else, for-loops, and so on. So, for example, if you want to create a function with a for-loop, you should use a user-defined function.
5 967
LAMBDA EXPRESSION
A lambda function is a small anonymous function.
A lambda function can take any number of arguments, but can only have one expression.
argument(s) is a placeholder, that is a variable that will be used to hold the value you want to pass into the function expression.
A lambda function can have multiple variables depending on what you want to achieve.
5 967
**KWARGS EXAMPLE 2 :
In this case, positional arguments are collected into a tuple args, and keyword arguments are collected into a dictionary kwargs
5 967
You can also use both args and kwargs together in a function definition, like this:
5 967
**KWARGS
kwargs is a dictionary of keyword arguments, which allows you to pass a variable number of keyword arguments to a function. The syntax for keyword arguments is name=value. For example:
5 967
*ARGS
args is a tuple of positional arguments, which means that you can pass an arbitrary number of arguments to a function, and they will be collected into a tuple. For example:
5 967
*ARGS AND **KWARGS IN PYTHON
In Python, args and kwargs are used to pass a variable number of arguments to a function.
