Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer

From 31 to 45 of 820

Q. ,i+j) print(test(4,7))

a. 13

b. 7

c. infinite loop

d. 17

  • d. 17

Q. 5 RECURSION

a. 011

b. 110

c. 3

d. infinite loop

  • b. 110

Q. 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 function

  • d. a function where the recursive call is the last thing executed by the function

Q. , tot-2)

a. both a() and b() aren’t tail recursive

b. both a() and b() are tail recursive

c. b() is tail recursive but a() isn’t

d. a() is tail recursive but b() isn’t

  • c. b() is tail recursive but a() isn’t

Q. 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 value

  • d. every recursive function must have a return value

Q. 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 thrown

  • a. program gets into an infinite loop

Q. 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 iteration

  • c. recursive calls take up less memory

Q. 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 equivalent

  • b. recursive functions are easy to debug

Q. Which of the following commands will create a list?

a. list1 = list()

b. list1 = []

c. list1 = list([1, 2, 3])

d. all of the mentioned

  • d. all of the mentioned

Q. What is the output when we execute list(“hello”)?

a. [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

b. [‘hello’]

c. [‘llo’]

d. [‘olleh’]

  • a. [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

Q. Suppose list1 is [2445,133,12454,123], what is max(list1)?

a. 2445

b. 133

c. 12454

d. 123

  • c. 12454

Q. Suppose list1 is [1, 5, 9], what is sum(list1)?

a. 1

b. 9

c. 15

d. error

  • c. 15

Q. 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)

  • c. random.shuffle(list1)
Subscribe Now

Get All Updates & News