Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rock Paper Scissors Coding

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Rock Paper Scissors Coding. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

RAMP Consulting Group is prototyping a lightweight code-review game for interview practice. Implement a function that determines the winner of one Rock Paper Scissors round.

Given two valid moves, player1 and player2, return "Player 1" if the first move wins, "Player 2" if the second move wins, or "Tie" when both moves are identical.

Formal Specification

  • Input: Two strings, player1 and player2. Each string is exactly one of "rock", "paper", or "scissors".
  • Output: A string containing "Player 1", "Player 2", or "Tie".
  • Rock beats scissors, scissors beats paper, and paper beats rock.

Constraints

  • player1 and player2 are lowercase strings
  • Each move is exactly one of "rock", "paper", or "scissors"
  • The function evaluates one round only

Function Signature

def rps_winner(player1, player2):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output