Home Uncategorised Python for Machine Learning Great Learning – Quiz Answers

Python for Machine Learning Great Learning – Quiz Answers

333
0

Question No: 1 All of the characters of a string “my_string” can be changed to uppercase using the function:

  • my_string.upper()
  • my_string.lower()
  • my_string.allupper()
  • my_string.alllower()

Question No: 2 my_string= ‘Smile smile s s’

my_string.count(‘s’)

The output for the following would be:

  • 2
  • 3
  • 4
  • 5

Question No: 3 Tuples are immutable

  • True
  • False

Question No: 4 tup1=(1,2,3,4,5,”a”,”b”)

tup1=[1:4]

Output for the following code will be:

  • (1,2,3,4,5)
  • (2,3,4,5,6)
  • (2,3,4,5)
  • (3,4,5,’a’)

Question No: 5 tup1=(2,3)

tup2=(4,5,6)

tup2 + tup1

Output for the following code will be:

  • (1,2,3,4,5,6)
  • (4,5,6,2,3)
  • (4,1,5,2,6,3)
  • (4,5,6)

Question No: 6 l1=[1,2,3,4]

l1.append(“Noice”)

Output for the following code will be:

  • [1,2,3]
  • [1,2,3,4]
  • [1,2,3,4,’Noice’]
  • [1,2]

Question No: 7 A list can be sorted using:

  • descend()
  • sort()
  • ascend()
  • None of the above

Question No: 8 l1=[1,2,3,”apple”,”banana”]

l1*3

The output for the following code will be:

  • [1,2,3,’apple’,’banana’,1,2,3,’apple’,’banana’,1,2,3,’apple’,’banana’]
  • [1,2,3,’apple’,’banana’]
  • [1,2,3,’apple’,’banana’,1,2,3,’apple’,’banana’]
  • [1,2,3,’apple’,’banana’,1,2,3,’apple’,’banana’,1,2,3,’apple’,’banana’,1,2,3,’apple’,’banana’]

Question No: 9 fruit={“Apple”:20, “Mango”:30, “Banana”:40}

fruit[“Grapes”]=50

Fruit

Output for the following code will be:

  • {‘Mango’:30, ‘Banana’:40}
  • {‘Apple:20, ‘Mango’:30, ‘Banana’:40}
  • {‘Apple:20, ‘Mango’:30, ‘Banana’:40, ‘Grapes’:50}
  • {‘Apple’:20, ‘Mango’:30}

Question No: 10 Suppose B is a subclass of A, to invoke the __init__ method in A from B, what is the line of code you should write?

  • A.__init__(self)
  • super(B, self).__init__()
  • A.__init__(B)
  • B.__init__(A)

Question No: 11 A_____________ in python is mutable.

  • list
  • tuple.

Question No: 12A___________ cannot have duplicate items.

  • list
  • set

LEAVE A REPLY

Please enter your comment!
Please enter your name here