Question: Python Why when you take off the self before pi it says: Did you define pi? class Circle: pi = 3.14 def __init__(self, diameter): print(Creating
Python
Why when you take off the "self" before pi it says: "Did you define pi?"
class Circle: pi = 3.14 def __init__(self, diameter): print("Creating circle with diameter {d}".format(d=diameter)) # Add assignment for self.radius here: self.radius = diameter/2 def circumference(self): return 2 * self.pi * self.radius
medium_pizza = Circle(12) teaching_table = Circle(36) round_room = Circle(11460)
print(medium_pizza.circumference()) print(teaching_table.circumference()) print(round_room.circumference())
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
