[Tutor] Concept related to python classes

Alan Gauld alan.gauld at yahoo.co.uk
Mon Sep 7 08:39:05 EDT 2020


On 07/09/2020 10:59, Manprit Singh wrote:

> class Triangle:
>     def __init__(self, a, b, c):
>         self.a = a
>         self.b = b
>         self.c = c
> 
>     def area(self):
>         s = (self.a + self.b + self.c) / 2
>         return (s * (s - self.a) * (s - self.b) * (s - self.c))**0.5
> 
>     def resize(self, a1, b1, c1):
>         self.a = a1
>         self.b = b1
>         self.c = c1


Yes, that looks more like what I'd expect to see.

BTW Thanks for posting the area equation, I'd never come across
Herons formula before and had to do some reading on Wikipedia :-)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list