CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List
Python Code Walkthrough #42

One Attribute Shared By All

mediumClasses

📄 Code

Read carefully — what does this print?
1class Dog:
2 legs: int = 4
3 
4 def __init__(self, name: str) -> None:
5 self.name: str = name
6 
7rex: Dog = Dog("Rex")
8fido: Dog = Dog("Fido")
9rex.legs = 3
10print(rex.legs, fido.legs, Dog.legs)
11Dog.legs = 5
12print(rex.legs, fido.legs)

🎯 Your Answer