Update Already Passed
What does the `__init__()` method do in a Python class?
A) It defines a method for initializing variables.
B) It is used to delete the object.
✔✔C) It is called when an object is created, initializing the object's attributes.
D) It checks if the object is initialized correctly.
Which of the following is the correct way to define a function in Python?
A) `function my_function():`
✔✔B) `def my_function():`
C) `function def my_function():`
D) `create function my_function():`
Which of these operators is used for floor division in Python?
A) `/`
B) `//`
✔✔C) `//`
1
,D) `%`
How can you check if a variable `x` is a list in Python?
A) `isinstance(x, list)`
✔✔B) `type(x) == list`
C) `x is list`
D) `x.type() == list`
What will the following code print: `print("5" * 3)`?
A) `5 5 5`
B) `555`
✔✔C) `555`
D) `15`
How do you create a set in Python?
✔✔A) `my_set = {1, 2, 3}`
B) `my_set = [1, 2, 3]`
C) `my_set = (1, 2, 3)`
2
, D) `my_set = set(1, 2, 3)`
Which of these methods can be used to add an element to a list in Python?
A) `list.add(3)`
✔✔B) `list.append(3)`
C) `list.insert(3)`
D) `list.extend(3)`
What will the following code return: `len("Hello World!")`?
✔✔A) `12`
B) `11`
C) `10`
D) `13`
Which of the following data types is mutable in Python?
A) String
B) Tuple
✔✔C) List
3