Input/Output Tests with random computer inputs?

Hi, I am putting some simple Python challenges together for my high school class. I have this challenge for a simple rock, paper, scissors game. I want to run an automatic test (input/output - Match) but part of the program is the computer generates a random number between 1 and 3 for an input. How can I represent that in the input field? Or should I not be using Match?
The solution program is here. How do I test it?

print ("----ROCK, PAPER, SCISSORS----")

import random

#generates a random number between 1 and 3

#asks the user to input their choice and stores it in a variable
user=int(input("Enter your choice:\n1=Rock\n2=Paper\n3=Scissors\n"))

#outputs the computer's move
print("The computer has chosen",computer)

#outputs a different string depending on the outcome of the game
if computer==user:
    print ("Tie game")
elif computer==1 and user==3:
    print ("Computer wins")
elif computer==2 and user==1:
    print ("Computer wins")
elif computer==3 and user==2:
    print ("Computer wins")
    print ("You Win!")
1 Like

You can use the input() syntax and check if the input is rock, paper, or scissors. Take this as an example:

name = input("What is your name? ")


For more info take a look at this documentation for input(): Python | User Input | Codecademy

1 Like

Thanks! My code works, including the input(), but I cannot make a Test that would test if a students code is correct - I’m just wondering if I can or not?

1 Like

Im not sure what you are asking. Can you elaborate?

1 Like

So if my student created a solution just like mine in my original post - then I want to run a test to check that it works - but because the first input is a randomly generated number by the computer, I cannot predict what it will be in the test - so I was wondering if there is a way that I do not know about, to test the solutions using the test feature of the education teams replits. Up to this point I have only used the ‘match’ tests but there doesn’t seem the scope within that to cope with this code. I have no idea how to use the regex test or even if that would be suitable or not?
Here is a screen shop of my options on the match test and what I would want it to be, but obvioulsy can’t.

I dont really know how to use the tests. @lena could probably help.

1 Like

You could modify this program so the first input is an integer s, which you use to seed the random number generator. After “import random”, do “random.seed(s)”. Then the correct output is completely determined by the inputs (the seed plus the regular user inputs).

If you solve this would you mind posting? I have this exact assignment for my python class but I have them live demo it for me in class instead. Pulling grades from tests for this assignment would be great

Yea - there are other ways I could do this to get the test to work, but I cannot ask my pupils to design their program, just to suit the test system - I want them to write their code in the way I teach them. If I can’t autograde then it is fine, but I was just hoping there was a way to do it that I didn;t know about lol.