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: lectures/python_oop.md
+28-30Lines changed: 28 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -799,36 +799,6 @@ Aim for clarity, not efficiency.
799
799
```{exercise-end}
800
800
```
801
801
802
-
803
-
```{exercise-start}
804
-
:label: oop_ex2
805
-
```
806
-
807
-
In an {ref}`earlier exercise <pyess_ex2>`, you wrote a function for evaluating polynomials.
808
-
809
-
This exercise is an extension, where the task is to build a simple class called `Polynomial` for representing and manipulating polynomial functions such as
The instance data for the class `Polynomial` will be the coefficients (in the case of {eq}`polynom`, the numbers $a_0, \ldots, a_N$).
819
-
820
-
Provide methods that
821
-
822
-
1. Evaluate the polynomial {eq}`polynom`, returning $p(x)$ for any $x$.
823
-
1. Differentiate the polynomial, replacing the original coefficients with those of its derivative $p'$.
824
-
825
-
Avoid using any `import` statements.
826
-
827
-
```{exercise-end}
828
-
```
829
-
830
-
## Solutions
831
-
832
802
```{solution-start} oop_ex1
833
803
:class: dropdown
834
804
```
@@ -865,6 +835,34 @@ print(F(0.5))
865
835
```{solution-end}
866
836
```
867
837
838
+
839
+
```{exercise-start}
840
+
:label: oop_ex2
841
+
```
842
+
843
+
In an {ref}`earlier exercise <pyess_ex2>`, you wrote a function for evaluating polynomials.
844
+
845
+
This exercise is an extension, where the task is to build a simple class called `Polynomial` for representing and manipulating polynomial functions such as
0 commit comments