You're not reading the latest revision of this page, which is
here.
Python
Python in problems
pythonevaluator
Checks the student's code.
\begin{pythonevaluator}
for i in range(1,50):
if(expected_sum(i) != sum(i)):
exit(11) # returns with grading code 11
exit(0) # returns with grading code 0
\end{pythonevaluator}
|
pythonfunction
Creates an author defined Python function.
\begin{pythonfunction}{expected_sum} # expected_sum is the name of the function
def expected_sum(n):
s = 0
for i in range(1,n+1):
s += i
return s
\end{pythonfunction}
|
pythonsolution
Creates a sample solution for the code fragment with the given name
\begin{pythonsolution}{sum}
def sum(n):
s = 0
for i in range(1,n):
s += i
return s
\end{pythonsosultion}
|
pythonanswer
Creates an input field for a code fragment. \pythonanswer[template]{name}
template can be used to define a template for the answer.
name is the identifier of the code fragment.\pythonanswer[
def sum(n):
s = \editable # creates an editable field for the student
for i in range(1,n+1):
\multilineEditable # creates an editable field for the student, which allows line breaks
return s
]{sum}
|
inlcude
Defines an include for a whole Python problem or a question of it \include{lid}
lid is the lid of the Python script that is meant to be included
includeAnswer
Defines an include of an answer for a question in a Python problem \includeAnswer[forced]{sum}. If forced isn't used, the sample solution is used instead of the user's answer, in case the user answered the question, that the answer is in, wrong.
forced the user answer is included, even if the corresponding question is answered wrong
sum is the name of the pythonanswer that is supposed to be included
pythongrading
Specifies the grade and feedback for a certain evaluator exit code. \pythongrading{exitcode}{grade}{feedback}
exitcode is the exit value
grade the grade value (number between 0 and 1)
feedback feedback that is displayed to the user in the correction view
\pythongrading{0}{1.0}{All tests ran and passed}
\pythongrading{10}{0.0}{This is not a 3x3 matrix}
\pythongrading{11}{0.0}{At least one element is zero}
\pythongrading{12}{0.0}{The determinant is not zero}
|
Python in articles
Creates an input field for Python code
\begin{pythoninput}{60}{20} # 60: the size of the field in columns # 20: the size of the field in rows
a11 = 1/4; # is the initial content of the field. It can be edited by the student
a12 = 2/3;
a21 = -1/5;
a22 = 3/5;
A = [ a11, a12; a21, a22 ];
A
\end{pythoninput}
|
Creates an input field for Python code \pythoninput{width}{height}
width the size of the field in columns
height the size of the field in rows
Creates a button that sends the contents of a Python input field to a Python process and displays the result in a Python output field
\pythonbutton[label]
label is the text on the button
pythonoutput
Creates a text field for output from Python \pythonoutput{width}{height}
width the size of the field in columns
height the size of the field in rows
Python scripts
Todo
WebMiau Examples
Examples