By "User" do you mean the student or the author? The "Expected" field of a test is used to grade the student's code so it doesn't make sense to set it from the student's code. You can set it from the question author's code using the '<<' button in your example above, but that's not helpful in that particular example because the code is randomised.

What exactly are you asking the students to write? If, say, you're asking them to print 20 random integers in [0, 20) followed by their sum and the count (always 20?), then you have to decide exactly what you will accept. Are you happy if the code prints the sequence 0 .. 19? How about if it prints the value 1 20 times? Both of those outcomes *could *occur at random but are most unlikely. But then so is the particular sequence generated by your sample program above.

While you might be able to write a complex grader (see "Template graders" in the documentation) to compute the probability that the student's output came from the random number generator, I'd recommend you instead try to ask the question in such a way that the output is deterministic. For example, if you can access the random number seed in Pascal you could ask students to write a function that takes the seed value, plus an integer *n *as parameters, sets the seed to the given value and prints *n* random numbers in the range [0, 20) plus their sum.

But it might be worth asking yourself exactly what skill you're trying to test? Do you want to know if students know how to call *random*? Or if they can fill an array with a sequence of integers provided by some function? Or if they can compute the sum of the elements of an array? The above example doesn't quite achieve any of those (e.g. the code could be written without using an array at all).