| ... |
... |
@@ -17,8 +17,13 @@ for i in range(1,50): |
| 17 |
17 |
exit(0) # returns with grading code 0 |
| 18 |
18 |
\end{pythonevaluator} |
| 19 |
19 |
``` |
| 20 |
|
-<!-- |
| 21 |
|
-[//]: ### pythonfunction |
|
20 |
+ |
|
21 |
+<div class="alert"> |
|
22 |
+Only use <code>==</code> or <code>!=</code> for integers.<br/> |
|
23 |
+For floats, use <code>np.isclose</code> or <code>np.allclose</code> instead - exact comparison rejects correct answers due to rounding. |
|
24 |
+</div> |
|
25 |
+ |
|
26 |
+### pythonfunction |
| 22 |
27 |
Creates an author defined Python function which can be used by the student as well as in pythonevaluator. |
| 23 |
28 |
``` |
| 24 |
29 |
\begin{pythonfunction}{expected_sum} # expected_sum is the name of the function |
| ... |
... |
@@ -29,7 +34,7 @@ def expected_sum(n): |
| 29 |
34 |
return s |
| 30 |
35 |
\end{pythonfunction} |
| 31 |
36 |
``` |
| 32 |
|
---> |
|
37 |
+ |
| 33 |
38 |
### pythonsolution |
| 34 |
39 |
Creates a sample solution for the code fragment with the given name |
| 35 |
40 |
``` |
| ... |
... |
@@ -39,7 +44,7 @@ def sum(n): |
| 39 |
44 |
for i in range(1,n): |
| 40 |
45 |
s += i |
| 41 |
46 |
return s |
| 42 |
|
-\end{pythonsosultion} |
|
47 |
+\end{pythonsolution} |
| 43 |
48 |
``` |
| 44 |
49 |
|
| 45 |
50 |
### pythonanswer |
| ... |
... |
@@ -79,6 +84,11 @@ Specifies the grade and feedback for a certain evaluator exit code. `\pythongrad |
| 79 |
84 |
\pythongrading{12}{0.0}{The determinant is not zero} |
| 80 |
85 |
``` |
| 81 |
86 |
|
|
87 |
+<div class="alert green"> |
|
88 |
+Always call <code>exit(n)</code> explicitly for every case, and define <code>\pythongrading{0}{...}</code> yourself.<br/> |
|
89 |
+An evaluator path without an explicit <code>exit(n)</code> silently gets a grade of 1.0. |
|
90 |
+</div> |
|
91 |
+ |
| 82 |
92 |
### Python scripts |
| 83 |
93 |
|
| 84 |
94 |
For the sake of reusability and separation of concerns, you can create Python scripts in WebMiau which you can then include in Python problems with the [include command](#include). Python scripts are just pure Python code. |
| 85 |
95 |
|