

InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
1. |
Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].(a) [(2**x) for x in range(0, 13)](b) [(x**2) for x in range(1, 13)](c) [(2**x) for x in range(1, 13)](d) [(x**2) for x in range(0, 13)]The question was posed to me in my homework.My query is from List Comprehension topic in section Lists & List Comprehension of Python |
Answer» Right ANSWER is (a) [(2**x) for x in range(0, 13)] |
|
2. |
What is the list comprehension equivalent for: list(map(lambda x:x**-1, [1, 2, 3]))?(a) [1|x for x in [1, 2, 3]](b) [-1**x for x in [1, 2, 3]](c) [x**-1 for x in [1, 2, 3]](d) [x^-1 for x in range(4)]This question was posed to me during a job interview.I'd like to ask this question from List Comprehension topic in chapter Lists & List Comprehension of Python |
Answer» Right answer is (c) [x**-1 for x in [1, 2, 3]] |
|
3. |
Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.(a) [x in range(1, 1000) if x%3==0](b) [x for x in range(1000) if x%3==0](c) [x%3 for x in range(1, 1000)](d) [x%3=0 for x in range(1, 1000)]The question was posed to me during an interview.My question is based upon List Comprehension in chapter Lists & List Comprehension of Python |
Answer» Correct ANSWER is (b) [X for x in range(1000) if x%3==0] |
|
4. |
Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop()?(a) [3, 4, 5, 20, 5, 25, 1](b) [1, 3, 3, 4, 5, 5, 20, 25](c) [3, 5, 20, 5, 25, 1, 3](d) [1, 3, 4, 5, 20, 5, 25]I got this question in an interview.I want to ask this question from Lists topic in division Lists & List Comprehension of Python |
Answer» Right choice is (a) [3, 4, 5, 20, 5, 25, 1] |
|
5. |
Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop(1)?(a) [3, 4, 5, 20, 5, 25, 1, 3](b) [1, 3, 3, 4, 5, 5, 20, 25](c) [3, 5, 20, 5, 25, 1, 3](d) [1, 3, 4, 5, 20, 5, 25]The question was asked by my college professor while I was bunking the class.Origin of the question is Lists in portion Lists & List Comprehension of Python |
Answer» The correct CHOICE is (c) [3, 5, 20, 5, 25, 1, 3] |
|
6. |
Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?(a) [3, 4, 5, 20, 5, 25, 1, 3, 34, 5](b) [1, 3, 3, 4, 5, 5, 20, 25, 34, 5](c) [25, 20, 5, 5, 4, 3, 3, 1, 34, 5](d) [1, 3, 4, 5, 20, 5, 25, 3, 34, 5]I have been asked this question during an online exam.This key question is from Lists in section Lists & List Comprehension of Python |
Answer» Right option is (a) [3, 4, 5, 20, 5, 25, 1, 3, 34, 5] |
|
7. |
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?(a) [3, 4, 5, 20, 5, 25, 1, 3](b) [1, 3, 3, 4, 5, 5, 20, 25](c) [25, 20, 5, 5, 4, 3, 3, 1](d) [3, 1, 25, 5, 20, 5, 4, 3]This question was addressed to me in an international level competition.Question is from Lists in division Lists & List Comprehension of Python |
Answer» The correct choice is (d) [3, 1, 25, 5, 20, 5, 4, 3] |
|
8. |
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?(a) 0(b) 4(c) 1(d) 2This question was posed to me during a job interview.The doubt is from Lists in chapter Lists & List Comprehension of Python |
Answer» The CORRECT OPTION is (d) 2 |
|
9. |
Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?(a) 0(b) 1(c) 4(d) 2This question was addressed to me by my school principal while I was bunking the class.This interesting question is from Lists in section Lists & List Comprehension of Python |
Answer» The correct OPTION is (d) 2 |
|
10. |
To remove string “hello” from list1, we use which command?(a) list1.remove(“hello”)(b) list1.remove(hello)(c) list1.removeAll(“hello”)(d) list1.removeOne(“hello”)This question was addressed to me during an online exam.My question comes from Lists in chapter Lists & List Comprehension of Python |
Answer» The correct answer is (a) list1.remove(“HELLO”) |
|
11. |
To insert 5 to the third position in list1, we use which command?(a) list1.insert(3, 5)(b) list1.insert(2, 5)(c) list1.add(3, 5)(d) list1.append(3, 5)I have been asked this question in an interview for job.The query is from Lists topic in chapter Lists & List Comprehension of Python |
Answer» Correct option is (b) list1.insert(2, 5) |
|
12. |
To add a new element to a list we use which command?(a) list1.add(5)(b) list1.append(5)(c) list1.addLast(5)(d) list1.addEnd(5)The question was asked in my homework.I would like to ask this question from Lists topic in chapter Lists & List Comprehension of Python |
Answer» RIGHT CHOICE is (b) list1.append(5) For EXPLANATION: We use the FUNCTION append to add an element to the list. |
|
13. |
Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:(a) [0, 1, 2, 3](b) [0, 1, 2, 3, 4](c) [0.0, 0.5, 1.0, 1.5](d) [0.0, 0.5, 1.0, 1.5, 2.0]I have been asked this question in an internship interview.This question is from Lists topic in portion Lists & List Comprehension of Python |
Answer» RIGHT choice is (c) [0.0, 0.5, 1.0, 1.5] BEST explanation: EXECUTE in the shell to verify. |
|
14. |
Suppose list1 is [1, 3, 2], What is list1 * 2?(a) [2, 6, 4](b) [1, 3, 2, 1, 3](c) [1, 3, 2, 1, 3, 2](d) [1, 3, 2, 3, 2, 1]The question was posed to me at a job interview.My question is taken from Lists topic in chapter Lists & List Comprehension of Python |
Answer» Right option is (C) [1, 3, 2, 1, 3, 2] |
|
15. |
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?(a) [2, 33, 222, 14](b) Error(c) 25(d) [25, 14, 222, 33, 2]I got this question at a job interview.The doubt is from Lists topic in division Lists & List Comprehension of Python |
Answer» RIGHT option is (a) [2, 33, 222, 14] The explanation is: EXECUTE in the SHELL to verify. |
|
16. |
Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?(a) Error(b) None(c) 25(d) 2This question was addressed to me in a national level competition.This interesting question is from Lists topic in portion Lists & List Comprehension of Python |
Answer» Correct answer is (c) 25 |
|
17. |
Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?(a) print(list1[0])(b) print(list1[:2])(c) print(list1[:-2])(d) all of the mentionedThis question was posed to me in an interview.The above asked question is from Lists topic in portion Lists & List Comprehension of Python |
Answer» Right answer is (d) all of the mentioned |
|
18. |
To shuffle the list(say list1) what function do we use?(a) list1.shuffle()(b) shuffle(list1)(c) random.shuffle(list1)(d) random.shuffleList(list1)This question was addressed to me in examination.This key question is from Lists in portion Lists & List Comprehension of Python |
Answer» RIGHT answer is (c) random.shuffle(LIST1) The explanation is: Execute in the SHELL to verify. |
|
19. |
Suppose list1 is [1, 5, 9], what is sum(list1)?(a) 1(b) 9(c) 15(d) ErrorThe question was posed to me in an online interview.I would like to ask this question from Lists topic in chapter Lists & List Comprehension of Python |
Answer» RIGHT answer is (C) 15 The EXPLANATION: Sum returns the sum of all elements in the LIST. |
|
20. |
Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?(a) 3(b) 5(c) 25(d) 1I have been asked this question during an interview.Question is taken from Lists in chapter Lists & List Comprehension of Python |
Answer» The CORRECT choice is (d) 1 |
|
21. |
Suppose list1 is [2445,133,12454,123], what is max(list1)?(a) 2445(b) 133(c) 12454(d) 123This question was posed to me in a national level competition.This interesting question is from Lists topic in section Lists & List Comprehension of Python |
Answer» The correct OPTION is (c) 12454 |
|
22. |
Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?(a) 5(b) 4(c) None(d) ErrorI had been asked this question in an interview for internship.My doubt stems from Lists in chapter Lists & List Comprehension of Python |
Answer» The CORRECT ANSWER is (a) 5 |
|
23. |
What is the output when we execute list(“hello”)?(a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’](b) [‘hello’](c) [‘llo’](d) [‘olleh’]This question was posed to me by my college director while I was bunking the class.This interesting question is from Lists in portion Lists & List Comprehension of Python |
Answer» Right answer is (a) [‘h’, ‘E’, ‘L’, ‘l’, ‘o’] |
|
24. |
Which of the following commands will create a list?(a) list1 = list()(b) list1 = [](c) list1 = list([1, 2, 3])(d) all of the mentionedI had been asked this question during an online interview.My question is from Lists topic in division Lists & List Comprehension of Python |
Answer» RIGHT CHOICE is (d) all of the mentioned Easy explanation - Execute in the SHELL to VERIFY |
|