Python 3 MCQ (SET-11) – Multiple Choice Questions and Answers

  1. What will be the output after the following statements?
    x = [‘hot’, ‘100’, True]
    weather, humid = x
    print(weather, humid)
    a. ValueError
    b. hot 100
    c. hot True
    d. hot 100 True
  2. What will be the output after the following statements?
    x = [‘hot’, ‘100’, True]
    x.remove(‘100’)
    weather, humid = x
    print(weather, humid)
    a. ValueError
    b. hot 100
    c. hot True
    d. hot 100 True
  3. What will be the output after the following statements?
    x = [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    x.sort()
    print(x)
    a. SortError
    b. [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    c. [‘a’, ‘A’, ‘b’, ‘B’, ‘c’, ‘C’]
    d. [‘A’, ‘B’, ‘C’, ‘a’, ‘b’, ‘c’]
  4. What will be the output after the following statements?
    x = [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    x.sort(key=str.lower)
    print(x)
    a. SortError
    b. [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    c. [‘a’, ‘A’, ‘b’, ‘B’, ‘c’, ‘C’]
    d. [‘A’, ‘B’, ‘C’, ‘a’, ‘b’, ‘c’]
  5. What will be the output after the following statements?
    x = [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    x.sort(key=str.swapcase)
    print(x)
    a. TypeError
    b. [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    c. [‘a’, ‘A’, ‘b’, ‘B’, ‘c’, ‘C’]
    d. [‘A’, ‘B’, ‘C’, ‘a’, ‘b’, ‘c’]
  6. What will be the output after the following statements?
    x = [‘a’, ‘b’, 1, 2, ‘A’, ‘B’]
    x.sort()
    print(x)
    a. TypeError
    b. [‘a’, ‘b’, ‘c’, ‘A’, ‘B’, ‘C’]
    c. [‘a’, ‘A’, ‘b’, ‘B’, ‘c’, ‘C’]
    d. [‘A’, ‘B’, ‘C’, ‘a’, ‘b’, ‘c’]
  7. What will be the output after the following statements?
    import random
    x = [‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’,
    ‘Saturday’, ‘Sunday’]
    print(x[random.randint(0, len(x) – 1)])
    a. IndexError
    b. A random day from all the seven days
    c. A random day from all the days except Sunday
    d. A random day from all the days except Monday
  8. What will be the output after the following statements?
    x = ‘Today is a nice day’ + \
    ‘ I will go for a walk today’
    print(x)
    a. SyntaxError
    b. Today is a nice day
    c. I will go for a walk today
    d. Today is a nice day I will go for a walk today
  9. What will be the output after the following statements?
    x = ‘Today is a nice day’
    x[9] = ‘not ‘
    print(x)
    a. TypeError
    b. Today is a nice day
    c. SyntaxError
    d. Today is not a nice day
  10. What will be the output after the following statements?
    x = ‘Today is a nice day’
    y = x[:9] + ‘not ‘ + x[9:]
    print(y)
    a. TypeError
    b. Today is a nice day
    c. SyntaxError
    d. Today is not a nice day
  11. What will be the output after the following statements?
    x = ‘Today is a nice day’
    y = x[:9] + ‘not ‘ + x[9:]
    print(x)
    a. TypeError
    b. Today is a nice day
    c. SyntaxError
    d. Today is not a nice day
  12. What will be the output after the following statements?
    x = ‘Today is not a nice day’
    x = ‘Today is a nice day’
    print(x)
    a. TypeError
    b. Today is a nice day
    c. SyntaxError
    d. Today is not a nice day
  13. What will be the output after the following statements?
    x = (‘Today’, ‘nice’, ‘day’)
    x[1] = ‘not’
    print(x)
    a. TypeError
    b. (‘Today’, ‘nice’, ‘day’)
    c. SyntaxError
    d. (‘Today’, ‘not’, ‘nice’, ‘day’)
  14. What will be the data type of the output after the following statements?
    x = (‘Today’)
    print(x)
    a. TypeError
    b. String
    c. Tuple
    d. List
  15. What will be the data type of the output after the following statements?
    x = (‘Today’,)
    print(x)
    a. TypeError
    b. String
    c. Tuple
    d. List
  16. What will be the data type of y after the following statements?
    x = [1, 2, 3, 4]
    y = tuple(x)
    a. TypeError
    b. String
    c. Tuple
    d. List
  17. What will be the data type of z after the following statements?
    x = [1, 2, 3, 4]
    y = tuple(x)
    z = list(y)
    a. TypeError
    b. String
    c. Tuple
    d. List
  18. What will be the data type of the output after the following statements?
    x = ‘Python’
    y = list(x)
    print(y)
    a. TypeError
    b. String
    c. Tuple
    d. List
  19. What will be the data type of the output after the following statements?
    x = ‘Python’
    y = tuple(x)
    print(y)
    a. TypeError
    b. String
    c. Tuple
    d. List
  20. What will be the output after the following statements?
    x = (‘Python’)
    print(x)
    a. (‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)
    b. Python
    c. P y t h o n
    d. (‘Python’)
  21. What will be the output after the following statements?
    x = (‘Python’,)
    print(x)
    a. (‘Python’,)
    b. Python
    c. P y t h o n
    d. (‘Python’)
  22. What will be the output after the following statements?
    x = [0, 2, 4, 6]
    print(tuple(x))
    a. [0, 2, 4, 6]
    b. (0, 2, 4, 6)
    c. 0, 2, 4, 6
    d. 0 2 4 6
  23. What will be the output after the following statements?
    x = (0, 2, 4, 6)
    print(list(x))
    a. [0, 2, 4, 6]
    b. (0, 2, 4, 6)
    c. 0, 2, 4, 6
    d. 0 2 4 6
  24. What will be the output after the following statements?
    x = ‘Python’
    print(list(x))
    a. (‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)
    b. (Python)
    c. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
    d. [‘Python’]
  25. What will be the output after the following statements?
    x = ‘Python’
    print(tuple(x))
    a. (‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)
    b. (Python)
    c. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
    d. [‘Python’]
  26. What will be the output after the following statements?
    x = [4, 5, 7, 8, 9]
    y = x
    y[1] = 6
    print(y)
    a. [4, 5, 7, 8, 9]
    b. [4, 5, 6, 7, 8, 9]
    c. [4, 6, 7, 8, 9]
    d. [4, 7, 8, 9]
  27. What will be the output after the following statements?
    x = [4, 5, 7, 8, 9]
    y = x
    y[1] = 6
    print(x)
    a. [4, 5, 7, 8, 9]
    b. [4, 5, 6, 7, 8, 9]
    c. [4, 6, 7, 8, 9]
    d. [4, 7, 8, 9]
  28. What will be the output after the following statements?
    def abc(z):
    z.append(44)
    x = [7, 8, 9]
    abc(x)
    print(x)
    a. [7, 8, 9]
    b. [7, 8, 9, 44]
    c. [7, 44, 8, 9]
    d. [44, 7, 8, 9]
  29. What will be the output after the following statements?
    import copy
    x = [5, 4, 3, 2, 1]
    y = copy.copy(x)
    x.append(6)
    print(y[-1])
    a. 5
    b. 6
    c. [5, 4, 3, 2, 1, 6]
    d. 1
  30. What will be the output after the following statements?
    import copy
    x = [5, 4, 3, 2, 1]
    y = copy.copy(x)
    x[2] = 6
    print(y[2])
    a. 3
    b. 6
    c. [5, 4, 6, 3, 2, 1]
    d. 4
  31. What will be the output after the following statements?
    import copy
    x = [5, 4, 3, 2, 1]
    y = [7, 8, 9]
    z = [x, y]
    a = copy.copy(z)
    x[2] = 6
    print(a)
    a. [[5, 4, 3, 2, 1], [7, 8, 9]]
    b. [[5, 4, 6, 2, 1], [7, 8, 9]]
    c. [5, 4, 6, 3, 2, 1]
    d. [5, 4, 6, 2, 1, 7, 8, 9]
  32. What will be the output after the following statements?
    import copy
    x = [5, 4, 3, 2, 1]
    y = [7, 8, 9]
    z = [x, y]
    a = copy.deepcopy(z)
    x[2] = 6
    print(a)
    a. [[5, 4, 3, 2, 1], [7, 8, 9]]
    b. [[5, 4, 6, 2, 1], [7, 8, 9]]
    c. [5, 4, 6, 3, 2, 1]
    d. [5, 4, 6, 2, 1, 7, 8, 9]
  33. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(x[‘year’])
    a. day
    b. KeyError
    c. Sunday
    d. 10
  34. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    for i in x.values():
    print(i, end=’ ‘)
    a. Sunday 10
    b. KeyError
    c. Sunday
    d. 10
  35. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    for i in x:
    print(i, end=’ ‘)
    a. Sunday 10
    b. day week
    c. Sunday
    d. 10
  36. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    for i in x.keys():
    print(i, end=’ ‘)
    a. Sunday 10
    b. day week
    c. Sunday
    d. 10
  37. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    for i in x.items():
    print(i, end=’ ‘)
    a. (‘day’, ‘Sunday’) (‘week’, 10)
    b. day week
    c. (‘week’, 10)
    d. (‘day’, ‘Sunday’)
  38. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(list(x.keys()))
    a. Sunday 10
    b. day week
    c. [‘day’, ‘week’]
    d. (day, week)
  39. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(tuple(x.items()))
    a. ((‘week’, 10), (‘day’, ‘Sunday’))
    b. (‘day’, ‘Sunday’) (‘week’, 10)
    c. [‘day’, ‘week’]
    d. (day, week)
  40. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(tuple(x.values()))
    a. Sunday 10
    b. (‘Sunday’, 10)
    c. [‘Sunday’, 10]
    d. 10
  41. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    for i, j in x.items():
    print(i, j, end=’ ‘)
    a. (‘day’, ‘Sunday’) (‘week’, 10)
    b. {‘day’:’Sunday’, ‘week’:10}
    c. ‘day’:’Sunday’, ‘week’:10
    d. day Sunday week 10
  42. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(‘day’ in x.values())
    a. Sunday
    b. True
    c. False
    d. day
  43. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(‘day’ in x.keys())
    a. Sunday
    b. True
    c. False
    d. day
  44. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(x.get(‘day’, ‘Friday’))
    a. Friday
    b. True
    c. Sunday
    d. day
  45. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(x.get(‘days’, ‘Friday’))
    a. Friday
    b. True
    c. Sunday
    d. day
  46. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(x.get(‘weak’, 5))
    a. 10
    b. 5
    c. Sunday
    d. day
  47. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(x.get(‘week’, 5))
    a. 10
    b. 5
    c. Sunday
    d. day
  48. What will be the output after the following statements?
    x = {‘day’:’Sunday’, ‘week’:10}
    print(x.get(‘year’, 2016))
    a. year
    b. 2016
    c. Sunday
    d. 10
  49. What will be the output after the following statements?
    x = {‘year’: 2016, ‘month’: ‘March’}
    if ‘day’ not in x:
    x[‘day’] = ‘Tuesday’
    print(x)
    a. (‘day’, ‘Tuesday’)
    b. {‘day’: ‘Tuesday’, ‘month’: ‘March’}
    c. ‘day’: ‘Tuesday’, ‘month’: ‘March’, ‘year’: 2016
    d. {‘day’: ‘Tuesday’, ‘month’: ‘March’, ‘year’: 2016}
  50. What will be the output after the following statements?
    x = {‘year’: 2016, ‘month’: ‘March’}
    x.setdefault(‘day’, ‘Tuesday’)
    print(x)
    a. (‘day’, ‘Tuesday’)
    b. {‘day’: ‘Tuesday’, ‘month’: ‘March’}
    c. ‘day’: ‘Tuesday’, ‘month’: ‘March’, ‘year’: 2016
    d. {‘day’: ‘Tuesday’, ‘month’: ‘March’, ‘year’: 2016}
SHARE:

Leave a Comment