9. Basic Python Interview Question Asked in Data Analytics Interviews - List*3 or multiply list

preview_player
Показать описание
#python #pandas #pythonShorts #DataAnalytics @AnalyticsBox

Basic Python Interview Question Asked in Data Analytics Interviews - List*3 or multiply each element in a list

Рекомендации по теме
Комментарии
Автор

You could also use a list comprehension, which is generally more performant.
list_2 = [x*3 for x in list_1]

tomtomsiesie
Автор

Using list conphension
List1=[1, 2,3]
Print( [ x*3 for x in List1])

mohammedsab
Автор

1. list_2=(x*3 for x in list_1)
(or)
2.list_2=[ ]
for i in list_1:
list_2.append(i*3)

srinivaskumarkollapudi
Автор

The second one can be done with list compression
list_2=[i*3 for i in list_1]

gesserriahi
Автор

Import numpy as np
L=[1, 2, 3]
new_arr=np.array(l)
new_arr=new_arr*3
Print(new_arr)

ashutoshgoyal
Автор

the code can be done in one line
print(list(map(lambda lst: lst*3, [1, 2, 3])))

skullyvalo
Автор

a = [1, 2, 3, 4]
b=[]
for i in a:
for j in range(3):
b.append(i)
print(b)

jithinrajmmwayanad
Автор

>>> Import numpy as np
>>> np.array(list_1) * 3

easypeasyph
Автор

L1= [1, 2, 3]
s=[]
For i in L1:
s.append(i*3)
Print(s)

mohammedsab
Автор

List1=[1, 2, 3]
For i in List1
Print(List1[i-1]*3)

Phaneetalks
Автор

Using lambda function

List1=[1, 2, 3]
List(map(x, 3, x*3, list:3)

mohammedsab
Автор

No way this is an interview question. I think I can get a job if this is what it’s like

sethgoode
Автор

(a, b, c)=(1, 2, 3)
print((a*3, b*3, c*3))
Why that much this is the simple code to get ur answer

True_software_programmer
Автор

lol i did but its too long i am new to python :)
list =[1, 2, 3, 4, 5, 7]

for i in list:
multiplay = i * i
print(multiplay)

views-reom