You're not reading the latest revision of this page, which is
here.
Python
python in problems
Environements
pythonevaluator
Checks the students 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}
|
Commands
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 # creats one editable line for the student
for i in range(1,n+1):
\multilineEditable # creates editable lines for the student, which are extendable of it
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}
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 value. \pythongrading{exitcode}{grade}{feedback}
exitcode
is the exit value
grade
the grade value (number between 0 and 1)
feedback
the LSP key of the internationalized feedback or a text message
\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
Envirenemonts
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}
|
Commands
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