Science, Final Exam, Multiple Choice
Questions and Answers Latest Version
Already Passed
What is the correct syntax for an `else` statement in Python?
a) `else {}`
b) `else:`
c) `else ():`
d) `if else:`
✔✔ b) `else:`
What is the correct way to import a module in Python?
a) `import module_name`
b) `import(module_name)`
c) `from module_name import *`
d) Both a and c
✔✔ d) Both a and c
1
,What is the output of the following code?
```python
x=3
y=x+2
print(y)
```
a) 3
b) 5
c) 6
d) 2
✔✔ b) 5
What is the correct syntax for a `for` loop in Python?
a) `for i in range(10):`
b) `for i = 0; i < 10; i++:`
c) `for (i = 0; i < 10; i++):`
d) `for i from 0 to 10:`
2
, ✔✔ a) `for i in range(10):`
Which of the following data types is immutable in Python?
a) List
b) Dictionary
c) Tuple
d) Set
✔✔ c) Tuple
What is the purpose of the `return` keyword in a function?
a) It terminates the function and does not provide a result.
b) It provides the value to the caller of the function.
c) It prints the result of the function.
d) It creates a new variable.
✔✔ b) It provides the value to the caller of the function.
Which of the following is used to comment a single line in Python?
a) `//`
3