Download our latest MNC Answers Application at Play Store. Download Now

Python 3 Functions and OOPs MCQs Solution | TCS Fresco Play

  1. Python 3 Functions and OOPs MCQs Solution | TCS Fresco Play

  2. Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website's information or data are solely for the purpose of knowledge and education.

    Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).

    All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!


  3. 1. The output of expression, k = [print(i) for i in "maverick" if i not in "aeiou"] is _.


    -----------------------------------------


    Prints all characters that are not vowels


    -----------------------------------------


  4. 2. What is the return type of function 'id'?

  5. ----


    int


    ----


  6. 3. The elements of an iterator can be accessed multiple times.


    -----


    False


    -----


  7. 4. A generator function can have multiple yield expressions.


    ----


    True


    ----


  8. 5. The output of the expression {0 if i%2 ==0 else 1 for i in range(8)} is .


    ------

    {0, 1}


    ------


  9. 6. What value does 'k' hold after executing the expression, k = [print(i) for i in "maverick" if i not in "aeiou"]?


    ----------------


    A list of None's


    ----------------


  10. 7. The output of the expression itertools.takewhile(lambda x: x<5, [1,4,6,4,1]) is _.


    ----- [1,4]

    -----


  11. 8. Which of the following types of arguments can be passed to a function?


    ---------------


    All the options


    ---------------


  12. 9. Which of the following are present in a function header?


    --------------------------------


    Function name and parameter list


    --------------------------------


  13. 10. What is the default return value of a Python function?


    ----


    None


    ----


  14. 11. The output of the expression [ chr(i) for i in [65, 66, 67] ] is _.


    --------------- ['A', 'B', 'C']

    ---------------


  15. 12. Generators consume more space in memory than the lists.


    ------


    False


    -----


  16. 13. What is the output of the following code? class A:

    def __init (self, x=5, y=4): self.x = x

    self.y = y


    def __str__(self):


    return 'A(x: {}, y: {})'.format(self.x, self.y)

    def __eq__(self, other):


    return self.x * self.y == other.x * other.y def f1():

    a = A(12, 3)


    b = A(3, 12)


    if (a == b): print(b != a) print(a)

    f1()


    ---------------


    False


    A(x: 12, y: 3)


    ---------------


  17. 14. What is the output of the following code? class A:

    x = 0


    def __init (self, a, b): self.a = a

    self.b = b


    A.x += 1


    def __init (self):


    A.x += 1


    def displayCount(self): print('Count : %d' % A.x)

    def display(self):


    print('a :', self.a, ' b :', self.b) a1 = A('George', 25000)

    a2 = A('John', 30000)


    a3 = A()


    a1.display() a2.display() print(A.x)


    ----------------


    Results in Error


    ----------------


  18. 15. What is the output of the following code? class class1:

    a = 1


    def f1(self): a = 2

    class1.a += 1 print(class1.a, end=' ') print(a, end=' ')

    class1().f1()


    class1().f1()


    ------- 2 2 3 2

    -------


  19. 16. What is the output of the following code? class grandpa(object):

    pass


    class father(grandpa): pass

    class mother(object):


    pass


    class child(mother, father): pass

    print(child. mro__)


    ---------------------------------------------------------------------------------


    (<class '__main .child'>, <class '__main .mother'>, <class '__main__.father'>,


    <class '__main__.grandpa'>, <class 'object'>)


    ---------------------------------------------------------------------------------


  20. 17. What is the output of the following code? class A:

    def __init (self): print('one')

    def f(self): print(float()) print(hex(-255))

    class B(A):


    def __init (self): print('two')

    def f(self):


    print(float()) print(hex(-42))

    x = B()


    x.f()


    ------


    two 0.0

    -0x2a


    ------


  21. 18. Which of the following keyword is used for creating a method inside a class?


    ---


    def


    ---


  22. 19. Which of the following statement sets the metaclass of class A to B?


    ---------------------


    class A:


    metaclass = B


    ---------------------


  23. 20. What is the output of the following code? class A:

    def __init (self, a = 5):


    self.a = a def f1(self):

    self.a += 10


    class B(A):


    def __init (self, b = 0): A. init (self, 4) self.b = b

    def f1(self):


    self.b += 10 x = B()

    x.f1()


    print(x.a,'-', x.b)


    -------- "4 - 10"

    --------


  24. 21. Which methods are invoked on entering into and exiting from the block of code written in 'with' statement?


    --------------------

    enter , exit


    --------------------


  25. 22. Which of the following method is used by a user-defined class to support '+' operator? Which of the following method is used by a user defined class to support '+' operator?

    -------


    add


    -------


  26. 23. How many except statements can a try-except block have?


    --------------


    More than zero


    --------------


  27. 24. When will the else part of try-except-else be executed?


    ------------------------


    When no exception occurs


    ------------------------


  28. 25. Which of the following exception occurs, when an integer object is added to a string object?


    ---------


    TypeError


    ---------


  29. 26. Which of the following execption occurs, when an undefined object is accessed?


    ---------


    NameError


    ---------


  30. 27. Which of the following exception occurs, when a number is divided by zero? Which of the following execption occurs, when a number is divided by zero?

    -----------------


    ZeroDivisionError


    -----------------


  31. 28. In which of the following scenarios, finally block is executed?


    ------


    Always


    ------


  32. 29. If a list has 5 elements, then which of the following exceptions is raised when 8th element is accessed?


    ----------


    IndexError


    ----------


  33. 30. The output of the expression '2' == 2 is .


    -----


    False


    -----


  34. 31. Which of the keyword is used to display a customised error message to the user? Which of the keyword is used to display a customized error message to the user?

    -----


    raise


    -----


  35. 32. Can one block of except statements handle multiple exception?


    --------------------------------------------


    Yes, like except NameError, SyntaxError, ...


    --------------------------------------------


  36. 33. In Python, which of the following files is mandatory to treat a folder as a package?


    -----------


    init .py


    -----------


  37. 34. Which of the following modules are used to deal with Data compression and archiving?

    ----------------------


    All of those mentioned


    ----------------------


  38. 35. Which of the following methods of 'random' module is used to pick a single element, randomly, from a given list of elements?


    ------


    choice


    ------


  39. 36. Which of the following module is not used for parsing command line arguments automatically?



    --------


    cmdparse


    --------


  40. 37. Which of the following statement retreives names of all builtin module names? Which of the following statement retrieves names of all builtin module names?

    ------------------------------------


    import sys; sys.builtin_module_names


    ------------------------------------

  41. 38. Which of the following modules is used to manage installtion, upgradation, deletion of other pacakages automatically?


    Which of the following modules is used to manage installation, upgrading, and deletion of other packages automatically?


    ---


    pip


    ---


  42. 39. Which of the following statement retreives names of all builtin objects?


    -------------------------------------


    import builtins; builtins.dict.keys()


    -------------------------------------


  43. 40. Any Python Script can act like a Module. State if the statement is True or False?


    ----


    True


    ----


  44. 41. Which of the following expression can be used to check if the file 'C:\Sample.txt' exists and is also a regular file?


    -----------------------------


    os.path.isfile(C:\Sample.txt)


    -----------------------------

  45. 42. Which of the following is not a way to import the module 'm1' or the functions 'f1' and 'f2' defined in it?


    ---------------------


    import f1, f2 from m1


    ---------------------


  46. 43. Which of the following keyword is necessary for defining a generator function?


    -----


    yield


    -----


  47. 44. The output of the expression {i:j for i in "abcd" for j in "kiwi"} is .


    ----------------------------------------


    {'a': 'i', 'd': 'i', 'c': 'i', 'b': 'i'}


    ----------------------------------------


  48. 45. Which methods are defined in an iterator class?


    ------------------


    iter__, __next


    ------------------


  49. 46. Which keyword is used for defining a function?


    ---


    def


  50. 47. How are variable length non-keyword arguments specified in the function heading?


    ---------------------------------------


    One star followed by a valid identifier


    ---------------------------------------


  51. 48. Which of the following variables stores documentation of a function?


    --------


    doc


    --------


  52. 49. The output of expression [x*y for x, y in zip([3,4],[5,6])] is .


    -------- [15, 24]

    --------


  53. 50. Generator expressions use brackets.


    --- ()

    ---


  54. 51. Which of the following error occurs, if an iterator is accessed, when it has no elements?

    -------------


    StopIteration


    -------------


  55. 52. The output of the expression 'list(itertools.dropwhile(lambda x: x<5, [1,4,6,4,1]))' is

    .


    ------- [6,4,1]

    -------


  56. 53. Which of the following modules contain functions that create iterators for efficient looping?


    ---------


    itertools


    ---------


  57. 54. Which of the following function call is correct?


    --------------- f(a=1, b=1, c=2)

    --------------


  58. 55. Which of the following brackets are used to define a set comprehension?


    ---


    {}


  59. 56. Can one block of except statements handle multiple exceptions?


    -------------------------------


    Yes, like


    except ( NameError, SyntaxError, ...)


    ---------------------------------


  60. 57. How are variable length keyword arguments specified in the function heading?


    ----------------------------------------


    Two stars followed by a valid identifier


    ----------------------------------------


  61. 58. Which of the following statement is not true about Python functions?


    -----------------------------------------------------------


    Non-keyword arguments can be passed after keyword arguments


    -----------------------------------------------------------


  62. 59. The output of the expression [(i.upper(), len(i)) for i in 'kiwi' ] is .


    ---------------------------------------- [('K', 1), ('I', 1), ('W', 1), ('I', 1)]

    ----------------------------------------


  63. 60. The output of expression [i**+1 for i in range(3)] is _.


--------- [0, 1, 2]

--------- 



**************************************************
Credit for the above notes, goes to the respective owners. 

If you have any queries, please feel free to ask on the comment section.
If you want MCQs and Hands-On solutions for any courses, Please feel free to ask on the comment section too.

Please share and support our page!