## Same questions for all copies on a different funtion

I wonder if somebody can help me with the following issue:

I would like to give each student a diferent text, in my case it is a logical function, and make nearly the same questions to all the students, but refering to each particular function.
So that the anssers would be dependant on the given text or function, so diferent for each student, but same for all questions of any student.

Hope I was clear enuoght.

### Replies (27)

#### RE: Same questions for all copies on a different funtion - Added by Luc Prik5 months ago

def lofu_or(m,n):
return m or n

#### RE: Same questions for all copies on a different funtion - Added by Paco Riviere5 months ago

Nice! I works.

I leave the full code for anybody interested:

%\usepackage{pythontex} % in preamble
\begin{pythontexcustomcode}{py}
def taulaveritat(hd):
print(r"\begin{tabular}{c c|c}")
print(r"$A$ & $B$ &  %s \\ \hline" % hd)
for m in range(0, 2):
for n in range(0, 2):
print(r"%d & %d & %d \\" % (m, n, lofu(m,n)))
print(r"\end{tabular}")
\end{pythontexcustomcode}

% Adding the next lines to any question we can build any truth table.
% Just changing the return expression and its name on the pyc command:
\begin{pycode}
def lofu(m,n):
return m or n
\end{pycode}

\pyc{taulaveritat("$OR$")}


So we can use any Python operator to build any truth table as or, and, not, NAND (not(and)), NOR not(ˆ), XOR (ˆ), XNOR not(ˆ)

« Previous 1 2 (26-27/27)