Questions and Answers Rated A+
What is the correct syntax for defining a function in Python?
a) `function myFunction():`
b) `def myFunction:`
✔✔ c) `def myFunction():`
d) `function def myFunction():`
Which of the following is used to handle exceptions in Python?
a) `try-except`
✔✔ b) `try-except-finally`
c) `catch-finally`
d) `throw-catch`
What is the output of the following code: `print(3 * 'abc')`?
a) `abcabcabc`
✔✔ b) `abcabcabcabcabcabc`
c) `abc abc abc`
1
,d) `abc abc`
How do you 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>`
What is the default return value of a Python function that does not have a `return` statement?
a) `None`
✔✔ b) `None`
c) `False`
d) `0`
Which of the following is used to import a module in Python?
a) `include`
b) `import module_name`
✔✔ c) `import module_name`
2
, d) `use module_name`
What is the output of the code `print('Hello' + 3)`?
a) `Hello3`
b) `Hello`
✔✔ c) `TypeError`
d) `Hello 3`
What type of loop is a `while` loop in Python?
✔✔ a) Indefinite loop
b) Definite loop
c) For loop
d) Iterative loop
How do you create an empty dictionary in Python?
a) `dict = []`
✔✔ b) `dict = {}`
c) `dict = ()`
3