Latest Version Already Passed
What is the correct syntax to create a list in Python?
a) `list = [1, 2, 3]`
b) `list = (1, 2, 3)`
c) `list = {1, 2, 3}`
d) `list = 1, 2, 3`
✔✔ a) `list = [1, 2, 3]`
Which of the following will remove all items from a list?
a) `list.clear()`
b) `list.remove_all()`
c) `list.delete()`
d) `list.reset()`
✔✔ a) `list.clear()`
What is the purpose of the `continue` statement in Python?
a) It terminates the current loop and moves to the next one.
1
,b) It stops the program entirely.
c) It continues to the next iteration of the loop.
d) It skips the current loop and moves to the end.
✔✔ c) It continues to the next iteration of the loop.
What is the correct syntax to check if a number is even in Python?
a) `if number % 2 == 0:`
b) `if number % 2 == 1:`
c) `if number / 2 == 0:`
d) `if number // 2 == 0:`
✔✔ a) `if number % 2 == 0:`
What is the output of the following code?
```python
x=5
y=2
print(x ** y)
2
,```
a) 7
b) 25
c) 10
d) 2
✔✔ b) 25
How do you define a class method in Python?
a) `def method_name(self):`
b) `method_name(self):`
c) `def method(self):`
d) `class method_name(self):`
✔✔ a) `def method_name(self):`
Which function is used to convert a string to a float in Python?
a) `float()`
b) `convert()`
c) `to_float()`
3
, d) `str_to_float()`
✔✔ a) `float()`
What will the following code print?
```python
x = "python"
print(x[0])
```
a) `p`
b) `y`
c) `o`
d) `n`
✔✔ a) `p`
Which of the following is a valid tuple?
a) `(1, 2, 3)`
b) `[1, 2, 3]`
4