Python Assessment: Sample Questions | Bryq

Updated:

Beginner

Intermediate

Advanced

Python Assessment: Sample Questions | Bryq

Updated:

Beginner

Intermediate

Advanced

These are three sample questions from Bryq’s Python assessment, a coding test for hiring Python developers and data professionals. The full assessment covers three levels: beginner, intermediate, and advanced, from core data types to functional programming. Questions test both Python concepts and the ability to read code and predict its output, with four options and one correct answer each.

Beginner

Question

Which of the following is used to store a collection of items in a fixed, ordered sequence that cannot be modified?

Select your answer

Tuple

Dictionary

Set

List

WHY IS THIS THE CORECT ANSWER

A tuple is ordered and immutable: once created, its items cannot be changed, added or removed. Lists are ordered but mutable, while sets are unordered.

Intermediate

Question

What will be the output of the following code?


`x = {'a': 1, 'b': 2}

print(x.get(‘c’, 0))`

Select your answer

`0`

`''`

`None`

`Error`

WHY IS THIS THE CORECT ANSWER

The .get() method returns the supplied default value when a key is missing. Here that default is 0; with no default it would return None, and only square-bracket access (x[‘c’]) raises a KeyError.

Advanced

Question

What will be the output of the following code?


`numbers = [1, 2, 3, 4, 5]

result = list(map(lambda x: x ** 2, numbers))

print(result)`

Select your answer

`[1, 4, 9, 16, 25]`

`[2, 4, 6, 8, 10]`

`[1, 2, 3, 4, 5]`

`Error`

WHY IS THIS THE CORECT ANSWER

map() applies the lambda to every item, and x ** 2 squares each value. The result is converted to a list, giving [1, 4, 9, 16, 25]; [2, 4, 6, 8, 10] would come from x * 2.

Ready to see Bryq in action?

Start hiring based on real data.

Ready to see Bryq in action?

Start hiring based on

real data.

Ready to see Bryq in action?

Start hiring based on real data.