Consider the class definition below. import math class Circle: a class to contain circles der _init__(self, xc, you, -1)

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Consider the class definition below. import math class Circle: a class to contain circles der _init__(self, xc, you, -1)

Post by answerhappygod »

Consider The Class Definition Below Import Math Class Circle A Class To Contain Circles Der Init Self Xc You 1 1
Consider The Class Definition Below Import Math Class Circle A Class To Contain Circles Der Init Self Xc You 1 1 (42.28 KiB) Viewed 36 times
Consider The Class Definition Below Import Math Class Circle A Class To Contain Circles Der Init Self Xc You 1 2
Consider The Class Definition Below Import Math Class Circle A Class To Contain Circles Der Init Self Xc You 1 2 (67.71 KiB) Viewed 36 times
Consider The Class Definition Below Import Math Class Circle A Class To Contain Circles Der Init Self Xc You 1 3
Consider The Class Definition Below Import Math Class Circle A Class To Contain Circles Der Init Self Xc You 1 3 (70.78 KiB) Viewed 36 times
Consider the class definition below. import math class Circle: a class to contain circles der _init__(self, xc, you, -1): he initiaire our circle with user inputs un self.x = x self.y - y self.radius or def_str_(self): return "X(), y(), radius (".format(self,x, self.y, self.radius) def circunference(self): w returns the circunference of the circle return math.pi. 2. self.radius def area(self): return math.pi.self.radius +2 def diameter(self): returns the diameter of the circle return 2. self.radius det inCircle(self, xp, yp): *** determines if point xp, yp is in the circle dmath.sqrt(xp - self.x)--2(yp - self.y)--2) if d < self.radius: return True else: return false What will print to the terminal if I run the following code: x = Circle(5) print(x) O <_main_Circle object at 0x7f9bc80647f0> Ox=0, y = 0, radius = 5 Ox=5, y =5, radius = 5 OX= 5, y = 0, radius = 1

Consider the class definition below: import math class Circle: a class to contain circles det init__(self, xc=, yc=8, r=1): an initialize our circle with user inputs self.x = XC self.y = ye self. radius - r def _str_(self): return "x = 0, y = {}, radius = {}".format(self.x, self.y, self.radius) def circumference(self): returns the circumference of the circle" return math.pi * 2 * self.radius def area(self): return math.pi * self.radius**2 def diameter(self): *** returns the diameter of the circle" return 2 * self.radius def inCircle(self, xp, yp): determines if point xp, yp is in the circle". d = math.sqrt((xp - self.x)**2 + (yp - self.y)**2) if d < self.radius: return True else: return false Explain the purpose of the lines in triple quotation marks at the beginning of each method and class definition. How is something in triple quotes different from a line starting with a hashtag symbol?

Consider the class definition below: import math class Circle: una class to contain circles def _init__(self, xc=®, yc=8, r=1): initialize our circle with user inputs self.x - XC self.y = yc self.radius - r def __str_(self): return "X = {}, y = {}, radius = {}".format(self.x, self.y, self.radius) def circumference(self): returns the circumference of the circle" return math.pi 2 * self.radius def area(self): return math.pi = self.radius**2 def diameter(self): returns the diameter of the circle" return 2 * self.radius def inCircle(self, xp, yp): determines if point xp, yp is in the circle d = math.sqrt((xp - self.x)**2 + (yp - self.y)**2) it d < self.radius: return True else: return false What is the purpose of the "self" argument in each method? Why is it necessary? If I create a circle assigned to the variable x, and then call x.diameter(), why do I not need to put anything in those parentheses?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply