Below questions were asked in interviews of companies. A subsequent blog will give out about the solutions.
Given a list of numbers and a number find two numbers in the list that sums up to the number given? If no such combination exists output should be “None”. [Facebook]
sample_list = [1, 2, 3, 4], 7 — (3, 4)
In a list where all numbers repeat thrice, there is one that only repeats twice. Find this number [Goldman Sachs]
sample_list = [1, 2, 1,1, 2, 2, 3, 3] — 3
When should you use a List vs a Tuple? [Saama Technologies]
How is copy different from assignment operator(‘=’). What is the difference between shallow and deep copy? [Saama Technologies]
a = b # a = b.copy() # a = copy.deepcopy(b)
What is the difference between iterators and generators? [Google]
The solutions will be provided in the next blog.
Learn21 conducts an online Boot Camp for web development. If interested you can check the details here.