WorksheetsMastering Python: Data Types & Functions
Total questions: 10
Worksheet time: 5mins
What is the data type of the variable `x` in the following Python code snippet? ```python x = 3.14 ```
int
float
str
bool
Which of the following is a valid way to define a function in Python?
`def my_function:`
`function my_function()`
`def my_function():`
`my_function() = function`
What will be the output of the following code? ```python x = "Hello" y = "World" z = x + " " + y print(z) ```
`HelloWorld`
`Hello World`
`Hello, World`
`World Hello`
Which of the following is NOT a built-in data type in Python?
list
tuple
array
dict
What is the output of the following code? ```python def add(a, b): return a + b result = add(3, 4) print(result) ```
7
34
`add(3, 4)`
None
Which of the following statements is used to import a module in Python?
`import module_name`
`include module_name`
`require module_name`
`using module_name`
What is the result of the following expression in Python? ```python 5 // 2 ```
2.5
2
3
2.0
Which of the following is the correct way to access the value associated with the key `'name'` in a dictionary `person`? ```python person = {'name': 'Alice', 'age': 25} ```
`person.name`
`person['name']`
`person(name)`
`person->name`
What will be the output of the following code? ```python def multiply(x, y=2): return x * y result = multiply(5) print(result) ```
10
5
25
Error
Which of the following is a mutable data type in Python?
tuple
string
list
int
