Home / Skill tests / Python

Python test: 10 questions to check yourself

In plain words: Python is a programming language known for short, readable code. It is used for websites, data work, automation and AI. Answer ten questions, press the button, and see which you got right and why.

9,277 open jobs name Python today, with a median advertised pay of $202K. The questions are the kind that come up in a first interview.

1What does len([4, 8, 15]) return?
2Which of these is a dictionary?
3What is the difference between a list and a tuple?
4What does this print? for i in range(3): print(i)
5What does a list comprehension such as [x * 2 for x in nums] do?
6A function is defined as def add(x, items=[]): items.append(x); return items . What does the second call of add(1) return?
7What is the result of "7" + "3"?
8What does the with keyword do in with open("data.txt") as f: ?
9Which statement catches an error so the program can carry on?
10What is the usual way to get the value of key "city" from a dictionary d, with no error if the key is missing?

Questions about this test

How do I prepare for a Python interview?
Work through realistic questions, read why each answer is right, then redo the ones you missed. This test has ten, taken from what interviewers commonly ask a beginner or a junior. Then read the postings: the 9,277 open jobs that name Python show what employers expect on top of it.
Is this Python test free?
Yes. It needs no account and no email, runs in your browser and sends nothing anywhere.
What does my score mean?
It is a self-check. Eight or more right means the basics are fresh; five to seven means a good base with gaps; under five means more practice first. It is not an official certificate.

More tests: SQL Excel JavaScript Linux Docker All tests