Photo by Glenn Carstens-Peters on Unsplash

How well do you know Python? Prove it with this Quiz.

hudbeard

--

A 5 question quiz to separate programmers from human code compliers. Stick around until the end for a chance to receive claps on your articles!

Follow me and Clap if you like this article. Comment your score on the quiz!

Python is everywhere nowadays, especially with AI on the rise. Here are 5 questions to test your understanding of the syntax and language of Python. All answers are at the end. No cheating! Comment your score when you are done! Don’t forget the bonus!

1. What is the result?

foo = (“I”, “Love”, “Programming”)
foo[2] = “Python”
print(foo)
A. ("I", "Love", "Python")
B. IndexError
C. TypeError
D. None of the above

2. Which is an int?

A. (3,)
B. 03
C. 3.0
D. (3)

3. What is the issue with this code?

def add_numbers(x, y)
return x + y
A. Functions cannot have underscores in the name
B. X and Y do not have an assigned type
C. Function is missing a colon
D. No issues

4. Any Errors?

for i in range(5):
if i = 3:
print("Found 3!")
A. Incorrect comparison operator
B. Incorrect indentation
C. Missing colon in loop
D. No issues

5. What is the result?

name = "hudbeard"
print("Hello, {name}")
A. ValueError
B. Hello, {name}
C. Hello, hudbeard
D. TypeError

Answers: (No peeking!)

  1. C. foo is a tuple. Tuples do not support index assignment or any sort of manipulation after being defined
  2. D. While (3) looks like another tuple, it actually is an integer. There must be a comma to define a tuple. (3,) is a tuple.
  3. C. Everything about this function is correct except it is missing a colon
  4. A. Comparison must be done with a double equal sign, not a single.
  5. B. The string is just a string, not an F-string

Congratulations! You did it! I hope you learned something regardless of your performance on the quiz. Comment your score!

Bonus! What is the result?

number = 0b10100 + 0b1010
print(f"Clap {number} times for this article!")

The first 10 people to comment the correct answer, and clap number times for this article, will get 0b10100 + 0b1010 claps on three of their articles!

Follow me and Clap if you like this article. Comment your score on the quiz! I want to hear it!

--

--

hudbeard

Professional software engineer since age 14. Programming since age 6. Python is my love language. 🐍