Advertisement
Guest User

Untitled

a guest
May 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. """
  2. ERRORS
  3. A. print(Triangle.mytriangle_area(self)) = NameError: name 'self' is not defined
  4. B. print(Triangle.mytriangle_area()) = TypeError: mytriangle_area() missing 1 required positional argument: 'self' (SEE LINE with comments BELOW)
  5. C. print(Triangle.mytriangle_area) = prints out '<function Triangle.mytriangle_area at 0x7f8f1a5fb620>'
  6. """
  7.  
  8. # ----------------------------------------------
  9.  
  10. import math
  11.  
  12. class Triangle:
  13. def __init__(self, base, height):
  14. self.base = base
  15. self.height = height
  16.  
  17. def triangle_area(self):
  18. return (self.base/2)*self.height
  19.  
  20.  
  21. goofy = Triangle(23.5, 35.4)
  22. print(goofy.triangle_area())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement