5 967
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-357 روز
-22530 روز
آرشیو پست ها
5 967
What an extraordinary moment! Heartiest congratulations to all Indians on the successful soft landing of #Chandrayaan3 🚀
Immense gratitude to ISRO for their dedication & brilliance in making this historic achievement possible 🇮🇳
5 967
200 Pages Full Python Course Pdf Download For Free 🚀
🔗 Link : https://shrs.link/kcHVMg
Watch The Video To Know How To Get Access To Pdf 🙏
5 967
Chapter 8th : FILE HANDLING
https://t.me/+owcuI4FCXxMxNDdl
https://t.me/+owcuI4FCXxMxNDdl
https://t.me/+owcuI4FCXxMxNDdl
https://t.me/+owcuI4FCXxMxNDdl
5 967
FILTER FUNCTION
The filter() method filters the given sequence with the help of a function that tests each element in the sequence to be true or not.
data = [1,2,3,4,5,5,6,6,7,9,10]
var = list(filter(lambda x : x%2==0 , data))
print(var)
Output :
[2, 4, 6, 6, 10]5 967
MIN FUNCTION
This function is used to compute the minimum of the values passed in its argument and lexicographically smallest value if strings are passed as arguments.
a = [4,328,38,62]
print("The Maximum Value Is : ",min(a))
Output :
45 967
MAX FUNCTION
This function is used to compute the maximum of the values passed in its argument and lexicographically largest value if strings are passed as arguments.
a = [4,328,38,62]
print("The Maximum Value Is : ",max(a))
Output :
The Maximum Value Is : 3285 967
REDUCE FUNCTION EXAMPLE :
from functools import reduce
li = [5, 9, 12, 22, 40, 95]
sum = reduce((lambda x, y: x + y), li)
print(sum)
Output :
1835 967
WORKING OF REDUCE FUNCTION
At first step, first two elements of sequence are picked and the result is obtained.
Next step is to apply the same function to the previously attained result and the number just succeeding the second element and the result is again stored.
This process continues till no more elements are left in the container.
The final returned result is returned and printed on console.
5 967
REDUCE FUNCTION
The reduce(fun,seq) function is used to apply a particular function passed in its argument to all of the list elements mentioned in the sequence passed along.This function is defined in “functools” module
5 967
ALL FUNCTION EXAMPLE :
list_1 = [2,4,6,8,10] # all even no
list_2 = [2,5,1,6,7] # all not even no
list_1check= all([num%2==0 for num in list_1])
list_2check= all([num%2==0 for num in list_2])
print(list_1check)
print(list_2check)
Output :
True
False5 967
ALL FUNCTION
All Returns true if all of the items are True (or if the iterable is empty). All can be thought of as a sequence of AND operations on the provided iterables. It also short circuit the execution i.e. stop the execution as soon as the result is known.
5 967
ANY FUNCTION EXAMPLE :
list_1 = [1,3,5,7,9] # all even no
list_2 = [3,5,6,11,7] # all not even no
list_1check= any([num%2==0 for num in list_1])
list_2check= any([num%2==0 for num in list_2])
print(list_1check)
print(list_2check)
Output:
False
True