August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 7 | User! Identify Yourself |
| | next_uid = 1 |
| | |
| | |
| | class User: |
| | def __init__(self, name): |
| | global next_uid |
| | |
| | self.name = name |
| | self.__id = next_uid |
| | next_uid += 1 |
| | |
| | |
| | u = User('daffy') |
| | print(f'name={u.name}, id={u.__id}') |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will raise an AttributeError exception.
Python does not have private and protected attributes like other ...
Read now
Unlock full access