You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Status/Day_13.md
+53-19Lines changed: 53 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,20 @@
1
1
2
2
# Question 47
3
-
### Level 2
3
+
###### Level 2
4
+
4
5
5
-
**Question:**
6
+
### Question
6
7
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
+
> ***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
9
10
----------------------
10
-
### Hints: Use def methodName(self) to define a method.
11
-
-------------------
11
+
### Hints
12
+
> ***Use def methodName(self) to define a method.***
13
+
14
+
---------------------
12
15
13
16
**Main author's Solution: Python 2**
14
-
```
17
+
```python
15
18
classCircle(object):
16
19
def__init__(self, r):
17
20
self.radius = r
@@ -24,7 +27,7 @@ print aCircle.area()
24
27
```
25
28
----------------
26
29
**My Solution: Python 3**
27
-
```
30
+
```python
28
31
classCircle():
29
32
def__init__(self,r):
30
33
self.radius = r
@@ -39,18 +42,20 @@ print(circle.area())
39
42
----------------
40
43
41
44
# Question 48
42
-
### Level 2
45
+
######Level 2
43
46
44
-
**Question:**
47
+
### Question
45
48
46
-
***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.***
49
+
> ***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.***
47
50
48
51
----------------------
49
-
### Hints: Use def methodName(self) to define a method.
50
-
-------------------
52
+
### Hints
53
+
> ***Use def methodName(self) to define a method.***
54
+
55
+
----
51
56
52
57
**Main author's Solution: Python 2**
53
-
```
58
+
```python
54
59
classRectangle(object):
55
60
def__init__(self, l, w):
56
61
self.length = l
@@ -65,7 +70,7 @@ print aRectangle.area()
65
70
```
66
71
----------------
67
72
**My Solution: Python 3**
68
-
```
73
+
```python
69
74
classRectangle():
70
75
def__init__(self,l,w):
71
76
self.length = l
@@ -84,17 +89,19 @@ print(rect.area())
84
89
# Question 49
85
90
### Level 2
86
91
87
-
**Question:**
92
+
### **Question**
88
93
89
-
***Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument. Both classes have a area function which can print the area of the shape where Shape's area is 0 by default.***
94
+
> ***Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument. Both classes have a area function which can print the area of the shape where Shape's area is 0 by default.***
90
95
91
96
----------------------
92
-
### Hints: To override a method in super class, we can define a method with the same name in the super class.
97
+
### Hints
98
+
> ***To override a method in super class, we can define a method with the same name in the super class.***
99
+
93
100
94
101
----------------------
95
102
96
103
**Main author's Solution: Python 2**
97
-
```
104
+
```python
98
105
classShape(object):
99
106
def__init__(self):
100
107
pass
@@ -115,7 +122,7 @@ print aSquare.area()
115
122
```
116
123
----------------
117
124
**My Solution: Python 3**
118
-
```
125
+
```python
119
126
classShape():
120
127
def__init__(self):
121
128
pass
@@ -136,6 +143,33 @@ print(Asqr.area()) # prints 25 as given argument
136
143
137
144
print(Square().area()) # prints zero as default area
0 commit comments