8 сентября 2022
🎯 *Morgan Stanley Drive 2022 | For Technology Full Time Analyst Program*
Degree: Any Graduate
Branch: Any Stream
Batch: 2018, 19, 20, 21, 22
Salary: INR 4.8 LPA*
Experience: Fresher
Apply Link:https://shrinke.me/JsKmEi
id 1353347414what is the difference between filter and map....its bit confusing can anyone explain plz..
First argument for filter is a function that returns a boolean. Filter applies that function on every element of the second argument and finally return those elements that that function returns true for them.
id 1353347414what is the difference between filter and map....its bit confusing can anyone explain plz..
map - apply function to every element of the iterable object. Which is why all elements are converted to capital
filter - it will filter the elements.. apply function on every element and return only those elements which evaluate to True
Ravi kumarI am unable to find logic to do it
In a case like this where you need to hold a key (language) and value (count) you can use a dictionary to save the values.
This way you can save lookup time and also have flexibility with adding values
id 1353347414how to write this programme using function...anyone plz..
Firstly you made a mistake naming the argument you're passing to function as 'b' but what u are using inside the function is 'k' (which I think it'd raise an error saying that k is not initialized or sth like this when u run the code)
Another thing that u gotta note is that ur function returns a list so it doesnt print the result just by calling it. U can put it in a print func or store it in a variable and then print that out.
id 1353347414how to write this programme using function...anyone plz..
Btw split is function so u gotta call it like this b.split(). U forgot the parentheses in ur code
МMFirstly you made a mistake naming the argument you're passing to function as 'b' but what u are using inside the function is 'k' (which I think it'd raise an error saying that k is not initialized or sth like this when u run the code)
Another thing that u gotta note is that ur function returns a lis
def a_e(k):
k.split()
a = []
for i in k:
if i[0]== "a" or i[0] == "e" or i[0]=="A" or i[0]=="E" :
a.append(i)
print(a)
return a
k = " hi eve how are you ? and how about your elvis "
a_e(k)
id 1353347414def a_e(k):
k.split()
a = []
for i in k:
if i[0]== "a" or i[0] == "e" or i[0]=="A" or i[0]=="E" :
a.append(i)
print(a)
return a
k = " hi eve how are you ? and how about your elvis "
a_e(k)
now output is like this ::: ['e', 'e', 'a', 'e', 'a', 'a', 'e']
id 1353347414now output is like this ::: ['e', 'e', 'a', 'e', 'a', 'a', 'e']
The split function doesn't change the string, so what you need to do is give that another variable name.
Something like str_split = k.split().
This was you can iterate over str_split and it'll be a list
id 1353347414now output is like this ::: ['e', 'e', 'a', 'e', 'a', 'a', 'e']
It's showing this way cause you're still iterating over the original string.