Member-only story
How I wrote a simple numbers game to play against the computer
In my last post I discussed how I entered a coding competition to create a simple numbers game in Python. The link for the post for the simple game that I programmed can be found here: How to program a simple numbers game using only numpy and pandas | by Tracyrenee | Python in Plain English | Feb, 2021 | Medium
Since I posted about the simple game that I have written, I modified the program so that one player plays against the computer. The way one person can play the computer in this game is to install a random integer generator that will create a number between one and nine, which takes on the role of the second player.
Python creates random numbers with the random module. Random number generators use mathematical formulas that transfer a set of numbers to another one. In Python I used the randint() function to create random integers between 1 and 9.
The challenge statement for this program reads as follows:-
“The Challenge
There are two players.
Each player writes a number, hidden from the other player. It can be any integer between 1 and 9.
The players reveal their numbers.
Whoever chose the lower number gets 1 point, unless the lower number is lower by only…