Small projectElementary20 XPExercise 14/16

Rock, paper, scissors

Task

Program rock – paper – scissors against the computer. So that even the computer's random move can be tested, split the program into functions:

  • tah_pocitaca() returns one of the words kamen (rock), papier (paper), noznice (scissors) at random,
  • vyhodnot(hrac, pocitac) returns, from the player's point of view, remiza (draw), vyhral si (you won) or prehral si (you lost). Rock blunts scissors, scissors cut paper and paper wraps rock.

The main part under if __name__ == "__main__": reads the player's choice; for an invalid one it prints neplatna volba, otherwise it prints the computer's choice and the result.

Examples

  • Call

    print(vyhodnot("kamen", "noznice"))

    Expected output

    vyhral si
  • Call

    print(vyhodnot("papier", "papier"))

    Expected output

    remiza

After you submit, 2 hidden tests will also check your solution: all 9 combinations, the computer's random move.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.