You’re Decent At Python If You Can Answer These 7 Questions Correctly
# No cheating pls!!
6 min readMar 6, 2024
Try to answer these questions without googling or using Python to test.
If you can answer all of them correctly without cheating, I can safely say that you’re probably pretty decent at Python!
1) @print???
@print
def testing():
print('hello!!')
return 1000
What does this do?
- A) Syntax error. There is no such thing as
@
in Python - B) this causes
testing()
to automatically print1000
when we call it - C) this prints
<function testing at 0x1023e2340>
- D) this prints
1000
automatically without us callingtesting()
- E)
testing()
's metadata will automatically print whenever it is called
2) *_ ???
a, b, *_ = [1, 2, 3, 4, 5]
print(_)
What does this print?
- A) Syntax error
- B)
[3, 4, 5]
- C)
[1, 2, 3, 4, 5]
- D)
<generator object <genexpr> at 0x1003847c0>
- E) NameError: ‘_’ is not a valid variable name