forum Computer Science Help
Started by Sunshine Love
tune

people_alt 65 followers

Sunshine Love

I have to use python to design a number guessing game for 2 players. The number has to be between 1 and 10. Basically, whichever player has the closest number to the randomized or "secret number" wins. I don't know how you code the part where the programs determines which player wins and if both players are tied.

@andrew health_and_safety flash_onAdmin

You probably want to take both players' guessed numbers and compare them to see which is closer to the secret number. You can just use subtraction (and take the absolute value of the result, to remove the negative) to see who's closer, and whichever one is closer is the winner (or, if they're both the same distance away, it's a tie). :)

(Also, I'm gonna move this over to General Chat since the Worldbuilding Technology board is more for creating fictional technologies)