Skip to content

Commit fa41b5b

Browse files
authored
Update Day_13.md
1 parent b905d31 commit fa41b5b

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Status/Day_13.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
11

2+
# Question 47
3+
### Level 1
4+
5+
**Question:**
6+
7+
***Define a class named Circle which can be constructed by a radius. The Circle class has a method which can compute the area. ***
8+
9+
----------------------
10+
### Hints: Use def methodName(self) to define a method.
11+
-------------------
12+
13+
**Main author's Solution: Python 2**
14+
```
15+
class Circle(object):
16+
def __init__(self, r):
17+
self.radius = r
18+
19+
def area(self):
20+
return self.radius**2*3.14
21+
22+
aCircle = Circle(2)
23+
print aCircle.area()
24+
```
25+
----------------
26+
**My Solution: Python 3**
27+
```
28+
```
29+
----------------
30+
31+
# Question 48
32+
### Level 1
33+
34+
**Question:**
35+
36+
***Define a class named Rectangle which can be constructed by a length and width. The Rectangle class has a method which can compute the area. ***
37+
38+
----------------------
39+
### Hints: Use def methodName(self) to define a method.
40+
-------------------
41+
42+
**Main author's Solution: Python 2**
43+
```
44+
class Rectangle(object):
45+
def __init__(self, l, w):
46+
self.length = l
47+
self.width = w
48+
49+
def area(self):
50+
return self.length*self.width
51+
52+
aRectangle = Rectangle(2,10)
53+
print aRectangle.area()
54+
55+
```
56+
----------------
57+
**My Solution: Python 3**
58+
```
59+
```
60+
----------------
61+

0 commit comments

Comments
 (0)