Explore topic-wise InterviewSolutions in .

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.

Which of these is not true about recursion?(a) It’s easier to code some real-world problems using recursion than non-recursive equivalent(b) Recursive functions are easy to debug(c) Recursive calls take up a lot of memory(d) Programs using recursion take longer time than their non-recursive equivalentI got this question during an interview for a job.I need to ask this question from Recursion in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

Correct choice is (b) Recursive functions are easy to DEBUG

The explanation: Recursive functions MAY be hard to debug as the LOGIC BEHIND recursion may be hard to follow.

2.

Which of these is not true about recursion?(a) Making the code look clean(b) A complex task can be broken into sub-problems(c) Recursive calls take up less memory(d) Sequence generation is easier than a nested iterationThe question was posed to me in exam.Asked question is from Recursion in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» RIGHT CHOICE is (c) RECURSIVE calls take up less memory

Explanation: Recursive calls take up a lot of memory and time as memory is taken up each time the FUNCTION is called.
3.

What happens if the base condition isn’t defined in recursive programs?(a) Program gets into an infinite loop(b) Program runs once(c) Program runs n number of times where n is the argument given to the function(d) An exception is thrownThis question was addressed to me in final exam.My question is based upon Recursion topic in chapter Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT option is (a) Program GETS into an INFINITE loop

The explanation is: The program will RUN until the system gets out of memory.
4.

Recursion and iteration are the same programming approach.(a) True(b) FalseI got this question by my college professor while I was bunking the class.The query is from Recursion topic in chapter Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

Correct OPTION is (b) False

Explanation: In recursion, the function calls itself till the base CONDITION is reached whereas iteration means repetition of process for EXAMPLE in for-loops.

5.

Which of the following statements is false about recursion?(a) Every recursive function must have a base case(b) Infinite recursion can occur if the base case isn’t properly mentioned(c) A recursive function makes the code easier to understand(d) Every recursive function must have a return valueThis question was posed to me in quiz.This is a very interesting question from Recursion in section Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

Correct choice is (d) Every recursive FUNCTION must have a return VALUE

Best explanation: A recursive function needn’t have a return value.

6.

What is tail recursion?(a) A recursive function that has two base cases(b) A function where the recursive functions leads to an infinite loop(c) A recursive function where the function doesn’t return anything and just prints the values(d) A function where the recursive call is the last thing executed by the functionI got this question in homework.The question is from Recursion topic in section Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

Correct OPTION is (d) A FUNCTION where the RECURSIVE call is the LAST thing executed by the function

For explanation: A recursive function is TAIL recursive when recursive call is executed by the function in the last.

7.

Which of these is false about recursion?(a) Recursive function can be replaced by a non-recursive function(b) Recursive functions usually take more memory space than non-recursive function(c) Recursive functions run faster than non-recursive function(d) Recursion makes programs easier to understandI had been asked this question during a job interview.Asked question is from Recursion topic in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

Correct CHOICE is (c) RECURSIVE functions run faster than non-recursive function

Explanation: The speed of a program USING RECURSION is slower than the speed of its non-recursive EQUIVALENT.

8.

Only problems that are recursively defined can be solved using recursion.(a) True(b) FalseThe question was asked during an internship interview.I would like to ask this question from Recursion topic in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

The CORRECT OPTION is (B) False

Explanation: There are many other problems can also be solved using RECURSION.

9.

Which is the most appropriate definition for recursion?(a) A function that calls itself(b) A function execution instance that calls another execution instance of the same function(c) A class method that calls another class method(d) An in-built method that is automatically calledI have been asked this question in semester exam.The above asked question is from Recursion topic in chapter Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» RIGHT answer is (b) A FUNCTION execution instance that CALLS another execution instance of the same function

The EXPLANATION is: The appropriate definition for a RECURSIVE function is a function execution instance that calls another execution instance of the same function either directly or indirectly.
10.

Where are the arguments received from the command line stored?(a) sys.argv(b) os.argv(c) argv(d) none of the mentionedThis question was addressed to me in a job interview.My doubt stems from Argument Parsing 2 topic in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT CHOICE is (a) sys.argv

Easy EXPLANATION - REFER DOCUMENTATION.
11.

How are required arguments specified in the function heading?(a) identifier followed by an equal to sign and the default value(b) identifier followed by the default value within backticks (“)(c) identifier followed by the default value within square brackets ([])(d) identifierThis question was posed to me in an interview for job.The query is from Argument Parsing 2 in portion Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT ANSWER is (d) identifier

Explanation: REFER DOCUMENTATION.
12.

How are default arguments specified in the function heading?(a) identifier followed by an equal to sign and the default value(b) identifier followed by the default value within backticks (“)(c) identifier followed by the default value within square brackets ([])(d) identifierI got this question during an internship interview.I would like to ask this question from Argument Parsing 2 in chapter Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

Right CHOICE is (a) IDENTIFIER followed by an EQUAL to sign and the default value

The EXPLANATION is: Refer documentation.

13.

What is the value stored in sys.argv[0]?(a) null(b) you cannot access it(c) the program’s name(d) the first argumentThis question was addressed to me by my college professor while I was bunking the class.This question is from Argument Parsing 2 in portion Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

The CORRECT ANSWER is (c) the program’s name

Explanation: REFER documentation.

14.

What is the type of sys.argv?(a) set(b) list(c) tuple(d) stringI have been asked this question by my college professor while I was bunking the class.I'm obligated to ask this question of Argument Parsing 2 in chapter Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

The CORRECT answer is (B) list

The BEST I can explain: It is a list of ELEMENTS.

15.

How many keyword arguments can be passed to a function in a single function call?(a) zero(b) one(c) zero or more(d) one or moreI have been asked this question in semester exam.Question is taken from Argument Parsing 1 topic in portion Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT OPTION is (C) zero or more

Explanation: Zero KEYWORD ARGUMENTS may be passed if all the arguments have default values.
16.

Which module in the python standard library parses options received from the command line?(a) getopt(b) os(c) getarg(d) mainI got this question in final exam.I would like to ask this question from Argument Parsing 2 in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT ANSWER is (a) getopt

The explanation: getopt parses options RECEIVED from the COMMAND LINE.
17.

How are variable length arguments specified in the function heading?(a) one star followed by a valid identifier(b) one underscore followed by a valid identifier(c) two stars followed by a valid identifier(d) two underscores followed by a valid identifierThe question was asked by my college professor while I was bunking the class.This intriguing question comes from Argument Parsing 2 in portion Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT option is (a) ONE star FOLLOWED by a VALID identifier

The best I can EXPLAIN: Refer documentation.
18.

What is the length of sys.argv?(a) number of arguments(b) number of arguments + 1(c) number of arguments – 1(d) none of the mentionedThe question was asked in an online quiz.Question is from Argument Parsing 1 in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

The CORRECT answer is (b) NUMBER of ARGUMENTS + 1

Explanation: The first argument is the name of the program itself. Therefore the length of sys.argv is one more than the number arguments.

19.

How are keyword arguments specified in the function heading?(a) one-star followed by a valid identifier(b) one underscore followed by a valid identifier(c) two stars followed by a valid identifier(d) two underscores followed by a valid identifierI had been asked this question during an online interview.This question is from Argument Parsing 1 in division Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer»

The correct OPTION is (c) TWO STARS followed by a valid identifier

The EXPLANATION is: Refer documentation.

20.

What is the type of each element in sys.argv?(a) set(b) list(c) tuple(d) stringI had been asked this question during an online interview.My doubt stems from Argument Parsing 1 in section Argument Passing, Global vs Local Variables, Shallow copy vs Deep copy and Recursion of Python

Answer» CORRECT CHOICE is (d) string

Best EXPLANATION: It is a LIST of STRINGS.