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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!