If I define a class variable, I would’ve expected any methods I create to be able to reference it. However, it doesn’t look to be the case. For example I defined class variable pi = 3.14, and then create a method that calculates the area, which is based on pi. I have to define it again in the method to avoid a typeError. Is this how it is, or did I miss something?
class Circle: pi = 3.14 def area(self, radius): pi = 3.14 area = pi * radius ** 2 return area