92- Which method is used to convert a string to lowercase?
Anonymous Quiz
77%
a) lower()
13%
b) to_lower()
7%
c) downcase()
3%
d) casefold()
93- Which method returns the number of occurrences of a substring in a string?
Anonymous Quiz
61%
a) count()
16%
b) find()
21%
c) index()
2%
d) search()
94- How do you check if a value is in a list?
Anonymous Quiz
70%
a) value in list
10%
b) list.has(value)
3%
c) list.contains(value)
17%
d) value.exists(list)
95- What does x.remove(2) do in a list?
Anonymous Quiz
50%
a) Removes the element with value 2
29%
b) Removes the element at index 2
2%
c) Removes the second element
20%
d) Removes the element at position 2
96- Which method adds multiple elements to a list?
Anonymous Quiz
36%
a) extend()
30%
b) append()
18%
c) insert()
16%
d) add()
97- What will be the result of print("abc" * 2)?
Anonymous Quiz
67%
a) abcabc
3%
b) aabbcc
9%
c) abc2
21%
d) SyntaxError
98- What is the output of print(3 == 3.0)?
Anonymous Quiz
49%
a) False
41%
b) True
5%
c) SyntaxError
5%
d) None
👍1👎1
99- Which operator is used for string concatenation in Python?
Anonymous Quiz
60%
a) +
18%
b) &
10%
c) -
12%
d) |
100- A class in Python can inherit from multiple classes at once.
Anonymous Quiz
80%
a) True
20%
b) False
ID:101
class Animal:
def sound(self):
return "Animal makes sound"
class Dog(Animal):
def sound(self):
return "Dog barks"
dog = Dog()
print(dog.sound())
ID:101 - What does the following Python code output?
Anonymous Quiz
14%
A) Animal makes sound
75%
B) Dog barks
6%
C) sound method is not defined in Dog
5%
D) None of the above
ID:102
class A:
def method(self):
return 'A method'
class B(A):
def method(self):
return 'B method'
obj = A()
print(obj.method())
ID:102 - What will the following Python code output?
Anonymous Quiz
55%
A) A method
29%
B) B method
13%
C) method is not defined
3%
D) None of the above
ID:103
class X:
def __init__(self, name):
self.name = name
def __eq__(self, other):
return self.name == other.name
x1 = X("Alice")
x2 = X("Alice")
print(x1 == x2)
ID:103 - What is the output of the following code?
Anonymous Quiz
77%
A) True
9%
B) False
11%
C) Error: __eq__ method is not valid
3%
D) None of the above
ID:104
x = 10
def func():
global x
x = 20
func()
print(x)
ID:104 - What will be the output of the following?
Anonymous Quiz
16%
A) 10
80%
B) 20
2%
C) Error
3%
D) None of the above
ID:105
class A:
def display(self):
print("Class A")
class B(A):
def display(self):
print("Class B")
class C(B):
pass
obj = C()
obj.display()
ID:105 - What will be the output of the following Python code?
Anonymous Quiz
12%
A) Class A
68%
B) Class B
17%
C) Error: display is not defined in class C
3%
D) None of the above
ID:106
x = [1, 2, 3]
x.append(4)
print(x)
ID:106 - What is the output of the following code?
Anonymous Quiz
88%
a) [1, 2, 3, 4]
6%
b) [1, 2, 3]
5%
c) [4, 1, 2, 3]
2%
d) [1, 2, 3, [4]]