Internadda
20:00

Python Dev & SWE Practice Test

1What is the primary difference between a Python list and a tuple?

Lists can store mixed data types, tuples cannot.
Tuples use square brackets [], lists use parentheses ().
Lists are mutable (changeable), tuples are immutable (unchangeable).
Lists are faster for iteration than tuples.

2What will the following Python code print?

my_dict = {'a': 1, 'b': 2, 'c': 3}
print(my_dict.get('d', 0))
KeyError
0
None
False

3Which of the following is used to define a block of code (like in a function or loop) in Python?

Curly braces {}
Parentheses ()
Semicolons ;
Indentation (spaces or tabs)

4What is the purpose of the `__init__` method in a Python class?

It's the constructor, used to initialize object attributes when an object is created.
It defines how the object should be represented as a string.
It's called automatically when the object is destroyed (garbage collected).
It's used for inheriting methods from a parent class.

5How do you open a file named `data.txt` in Python for reading its content?

`file = open("data.txt", "w")`
`file = open("data.txt", "a")`
`with open("data.txt", "r") as file:`
`read("data.txt")`

6What does the `*args` syntax in a Python function definition allow?

Passing keyword arguments only.
Passing a variable number of positional arguments.
Defining default argument values.
Specifying the return type of the function.

7Which of the following is NOT a standard Python built-in data type?

int
dict
list
array (standard arrays are typically from the `array` module or NumPy)

8What is the output of `list(range(1, 5))`?

[1, 2, 3, 4]
[1, 2, 3, 4, 5]
[0, 1, 2, 3, 4]
(1, 2, 3, 4)

9What is the primary function of a `virtual environment` in Python development?

To automatically format Python code according to PEP 8.
To speed up the execution of Python scripts.
To isolate project dependencies and avoid conflicts between different projects.
To provide an interactive Python shell (REPL).

10Which keyword is used to handle potential errors in a block of Python code?

`catch`
`try` / `except`
`if error`
`handle`

Great Job! You're Ready!

Needs Improvement

Don't worry! Try again after reviewing the course material.

Warning: Focus Lost

You navigated away from the practice test tab. In a real exam, this could lead to disqualification. Click Resume to continue.

Practice Test Cancelled

Multiple instances of navigating away from the test tab were detected. To maintain fairness simulation, this practice session has been cancelled.