Puzzle 1: Ready Player One
Let’s exercise our brain by solving a Python attribute lookup puzzle.
We'll cover the following
Guess the output
Try to guess the output of the code below:
class Player:# Number of players in the Gamecount = 0def __init__(self, name):self.name = nameself.count += 1p1 = Player('Parzival')print(Player.count)
Quiz- Puzzle 1
Q
What is the expected output of the above code?
A)
0
B)
1
C)
The code throws a TypeError
exception.
D)
The code throws an AttributeError
exception.