Skip to content

Commit 923b67e

Browse files
authored
Update Day_13.md
1 parent dc273b9 commit 923b67e

File tree

1 file changed

+53
-19
lines changed

1 file changed

+53
-19
lines changed

Status/Day_13.md

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11

22
# Question 47
3-
### Level 2
3+
###### Level 2
4+
45

5-
**Question:**
6+
### Question
67

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.***
89
910
----------------------
10-
### Hints: Use def methodName(self) to define a method.
11-
-------------------
11+
### Hints
12+
> ***Use def methodName(self) to define a method.***
13+
14+
---------------------
1215

1316
**Main author's Solution: Python 2**
14-
```
17+
```python
1518
class Circle(object):
1619
def __init__(self, r):
1720
self.radius = r
@@ -24,7 +27,7 @@ print aCircle.area()
2427
```
2528
----------------
2629
**My Solution: Python 3**
27-
```
30+
```python
2831
class Circle():
2932
def __init__(self,r):
3033
self.radius = r
@@ -39,18 +42,20 @@ print(circle.area())
3942
----------------
4043

4144
# Question 48
42-
### Level 2
45+
###### Level 2
4346

44-
**Question:**
47+
### Question
4548

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.***
4750
4851
----------------------
49-
### Hints: Use def methodName(self) to define a method.
50-
-------------------
52+
### Hints
53+
> ***Use def methodName(self) to define a method.***
54+
55+
----
5156

5257
**Main author's Solution: Python 2**
53-
```
58+
```python
5459
class Rectangle(object):
5560
def __init__(self, l, w):
5661
self.length = l
@@ -65,7 +70,7 @@ print aRectangle.area()
6570
```
6671
----------------
6772
**My Solution: Python 3**
68-
```
73+
```python
6974
class Rectangle():
7075
def __init__(self,l,w):
7176
self.length = l
@@ -84,17 +89,19 @@ print(rect.area())
8489
# Question 49
8590
### Level 2
8691

87-
**Question:**
92+
### **Question**
8893

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.***
9095
9196
----------------------
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+
93100

94101
----------------------
95102

96103
**Main author's Solution: Python 2**
97-
```
104+
```python
98105
class Shape(object):
99106
def __init__(self):
100107
pass
@@ -115,7 +122,7 @@ print aSquare.area()
115122
```
116123
----------------
117124
**My Solution: Python 3**
118-
```
125+
```python
119126
class Shape():
120127
def __init__(self):
121128
pass
@@ -136,6 +143,33 @@ print(Asqr.area()) # prints 25 as given argument
136143

137144
print(Square().area()) # prints zero as default area
138145
```
146+
---------------------
147+
148+
149+
150+
# Question 50
151+
###### Level 2
152+
153+
154+
### Question
155+
156+
> ***Please raise a RuntimeError exception.***
157+
158+
----------------------
159+
### Hints
160+
> ***UUse raise() to raise an exception.***
161+
162+
-----------
163+
164+
165+
**Solution:**
166+
```python
167+
raise RuntimeError('something wrong')
168+
```
169+
170+
----------------
171+
172+
139173

140174
## Conclusion
141175

0 commit comments

Comments
 (0)