Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
33 lines (28 loc) · 918 Bytes

File metadata and controls

33 lines (28 loc) · 918 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import sys
import os
import math
class Shape:
"""Shape class: has method move"""
def __init__(self, x, y):
self.x = x
self.y = y
def move(self, deltaX, deltaY):
self.x = self.x + deltaX
self.y = self.y + deltaY
class Square(Shape):
"""Square Class: inherits from Shape"""
def __init__(self, side=1, x=0, y=0):
Shape.__init__(self, x, y)
self.side = side
class Circle(Shape):
"""Circle Class: inherits from Shape and has method area"""
def __init__(self, r=1, x=0, y=0):
Shape.__init__(self, x, y)
self.radius = r
def area(self):
"""Area of a Cirle is pi multipled by square of radius"""
return math.pi * math.pow(self.radius, 2)
def __str__(self):
return "Circle of radius {0} at coordinates ({1}, {2})".\
format(self.radius, self.x, self.y)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.