Python Practice Test MCQ Certified Go from 0 to Expert hero Set 29

What will be the output of the following Python code?


Options are :

  • 13
  • 7
  • Infinite loop
  • 17

Answer :17

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 12

What will be the output of the following Python code?


Options are :

  • 011
  • 110
  • 3
  • Infinite loop

Answer :110

What is tail recursion?


Options are :

  • A recursive function that has two base cases
  • A function where the recursive functions leads to an infinite loop
  • A recursive function where the function doesn't return anything and just prints the values
  • A function where the recursive call is the last thing executed by the function

Answer :A function where the recursive call is the last thing executed by the function

Observe the following Python code?


Options are :

  • Both a() and b() aren't tail recursive
  • Both a() and b() are tail recursive
  • b() is tail recursive but a() isn't
  • a() is tail recursive but b() isn't

Answer :b() is tail recursive but a() isn't

Python Certification Exam Preparation Set 3

Which of the following statements is false about recursion?


Options are :

  • Every recursive function must have a base case
  • Infinite recursion can occur if the base case isn't properly mentioned
  • A recursive function makes the code easier to understand
  • Every recursive function must have a return value

Answer :Every recursive function must have a return value

What will be the output of the following Python code?


Options are :

  • 50
  • 100
  • 74
  • Infinite loop

Answer :100

Recursion and iteration are the same programming approach.


Options are :

  • True
  • False

Answer :False

Python Certification Exam Preparation Set 66

What happens if the base condition isn't defined in recursive programs?


Options are :

  • Program gets into an infinite loop
  • Program runs once
  • Program runs n number of times where n is the argument given to the function
  • An exception is thrown

Answer :Program gets into an infinite loop

Which of these is not true about recursion?


Options are :

  • Making the code look clean
  • A complex task can be broken into sub-problems
  • Recursive calls take up less memory
  • Sequence generation is easier than a nested iteration

Answer :Recursive calls take up less memory

Which of these is not true about recursion?


Options are :

  • It's easier to code some real-world problems using recursion than non-recursive equivalent
  • Recursive functions are easy to debug
  • Recursive calls take up a lot of memory
  • Programs using recursion take longer time than their non-recursive equivalent

Answer :Recursive functions are easy to debug

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 17

What will be the output of the following Python code?


Options are :

  • 0 1 2 3
  • An exception is thrown
  • 0 1 1 2 3
  • 0 1 1 2

Answer :0 1 1 2

Which type of copy is shown in the following python code?


Options are :

  • Shallow copy
  • Deep copy
  • memberwise
  • All of the mentioned

Answer :Shallow copy

What will be the output of the following Python code?


Options are :

  • [88, 2, 3, [4, 5]] [88, 2, 3, [4, 5]]
  • [2, 3, [4, 5]] [88, 2, 3, [4, 5]]
  • [88, 2, 3, [4, 5]] [2, 3, [4, 5]]
  • [2, 3, [4, 5]] [2, 3, [4, 5]]

Answer :[2, 3, [4, 5]] [88, 2, 3, [4, 5]]

Python Certification Exam Preparation Set 52

In _______________ copy, the base address of the objects are copied. In _______________ copy, the base address of the objects are not copied.


Options are :

  • deep. shallow
  • memberwise, shallow
  • shallow, deep
  • deep, memberwise

Answer :shallow, deep

The nested list undergoes shallow copy even when the list as a whole undergoes deep copy.


Options are :

  • True
  • False

Answer :True

What will be the output of the following Python code and state the type of copy that is depicted?


Options are :

  • [2, 4, 6, 8], shallow copy
  • [2, 4, 6, 8], deep copy
  • [1, 2, 3], shallow copy
  • [1, 2, 3], deep copy

Answer :[1, 2, 3], shallow copy

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 3

What will be the output of the following Python code?


Options are :

  • False, False
  • False, True
  • True, True
  • True, False

Answer :True, False

What will be the output of the following Python code?


Options are :

  • True
  • False
  • Error
  • Address of l1

Answer :False

What will be the output of the following Python code?


Options are :

  • [10, 20, 30, [40]] [10, 20, 30, 90]
  • Error
  • [10, 20, 30 [90]] [10, 20, 30, [40]]
  • [10, 20, 30, [40]] [10, 20, 30, [90]]

Answer :[10, 20, 30 [90]] [10, 20, 30, [40]]

Python Certification Exam Preparation Set 30

In ____________________ copy, the modification done on one list affects the other list. In ____________________ copy, the modification done on one list does not affect the other list.


Options are :

  • shallow, deep
  • memberwise, shallow
  • deep, shallow
  • deep, memberwise

Answer :shallow, deep

What will be the output of the following Python code?


Options are :

  • [1, 2, 3, (4)] [1, 2, 3, 4]
  • [1, 2, 3, 4] [1, 2, 3, (4)]
  • [1, 2, 3, 4] [1, 2, 3, 4]
  • [1, 2, 3, (4)] [1, 2, 3, (4)]

Answer :[1, 2, 3, 4] [1, 2, 3, 4]

What will be the output of the following Python code?


Options are :

  • False
  • True
  • 1
  • An exception is thrown

Answer :False

Python Certification Exam Preparation Set 2

What is the base case in the Merge Sort algorithm when it is solved recursively?


Options are :

  • n=0
  • n=1
  • A list of length one
  • An empty list

Answer :A list of length one

What will be the output of the following Python code?


Options are :

  • 1 2 3 4 5
  • [5,4,3,2,1]
  • []
  • Error, lambda functions can't be called recursively

Answer :[]

What will be the output of the following Python code?


Options are :

  • [0, 2, 4, 6, 8, 10]
  • [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  • [1, 3, 5, 7, 9]
  • Error

Answer :[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Python Certification Exam Preparation Set 32

What will be the output of the following Python code?


Options are :

  • False True
  • False False
  • True True
  • True False

Answer :False True

What will be the output of the following Python code?


Options are :

  • Error
  • 10
  • 24
  • No output

Answer :24

What will be the output of the following Python code?


Options are :

  • [1, 4, 5 ]
  • Error
  • [-2, -3]
  • [1, -2, -3]

Answer :[1, -2, -3]

Python Certification Exam Preparation Set 60

What will be the output of the following Python code?


Options are :

  • [-4, 16]
  • Address of m
  • Error
  • -4 16

Answer :Address of m

What will be the output of the following Python code?


Options are :

  • [False, False, False, False, False]
  • [False, True, True, False, False]
  • [True, False, False, True, True]
  • [True, True, True, True, True]

Answer :[False, True, True, False, False]

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions