Saturday, December 6, 2025

Basic vs. Python: Numeric Guessing Games (Featuring Casio fx-702P and fx-CG100)

Basic vs. Python: Numeric Guessing Games


Calculators Used


Basic: Casio fx-702P

Python: Casio fx-CG100


Task


Generate two simple number guessing games.


Guess the Number


This is the classic guess the number. The game generates a number (positive integer) at random in a given range. The player guess the number and if it doesn’t match the target number, the player is told whether the target number is lower or higher. The objective is to find the target number in the lowest number of turns.


The pricing game, The Clock Game, from the legendary game show The Price Is Right uses the Guess the Number game for two prizes. The Clock Game, the contestant needs to get the three-digit price correct for each prize within a total of 30 seconds, with the host (Drew Carey or the late Bob Barker) informing the contest whether the correct price is higher or lower.


The code is for a game where the target integer is between 10 and 99.


BASIC: Casio fx-702P


10 PRT "GUESS THE NUMBER"

20 T=INT (RAN#*90+10)

30 C=0

40 G=0


100 INP "GUESS (10-99)",G

110 IF G<10 THEN 100

115 IF G>99 THEN 100

120 C=C+1

130 IF G<T;PRT "HIGHER"

140 IF G>T;PRT "LOWER"

150 IF G=T THEN 200

160 GOTO 100


200 PRT "CORRECT! THE # IS ";T

210 PRT "# GUESSES: ";C


PYTHON: Casio fx-CG100

Script: numguess.py


from random import *


print("Guess the number ")

t=int(random()*90+10)

c=0

g=0


# != means not

while t!=g:

  g=int(input("Guess (10-99)? "))

  c+=1

  if g<t:

    print("HIGHER")

  if g>t:

    print("LOWER")


# exact guess leaves the loop


print("CORRECT! The # is "+str(t)+".")

print("# of guesses: "+str(c))


The major difference between the two programs is that the Basic version uses If statements and Goto line statements, while Python code uses a while loop.


Find the Coin


This is a guessing game where the player is tasked to find a coin in a 10 by 10 grid. The rows and columns are labeled 0 through 9.





BASIC: Casio fx-702P


10 PRT "FIND THE COIN ($)"

30 A=INT (RAN#*10)

40 B=INT (RAN#*10)

50 C=0

60 PRT "GRID 0-9,0-9"


70 INP "X (0-9)",X

80 INP "Y (0-9)",Y

90 R=ABS (A-X)

100 S=ABS (Y-B)

105 C=C+1

110 IF R=S THEN 200

120 PRT S;" ROW";R;" COL"

150 GOTO 70


200 PRT "YOU FOUND IT!"

210 PRT "SCORE= ";C


PYTHON: Casio fx-CG100

Script: findcoin.py


# find the coin, 10 x 10 grid


from random import *

print("FIND THE COIN")

# random integer from 0 to 9

a=randint(0,9)

b=randint(0,9)

c=0

print("GRID 0-9,0-9")


# set up 

r=-1

s=-2


while r!=s:

  x=int(input("X 0-9: "))

  y=int(input("Y 0-9: "))

  r=abs(a-x)

  s=abs(b-y)

  c+=1

  if r==s:

    break

  print(str(s)+" rows "+str(r)+" col")


print("You found it!")

print("SCORE= ",str(c))


Note: Both numguess.py and findcoin.py use the random module, hence it can be adopted on every calculator with a random module. The HP Prime’s random module is urandom.


Have fun, and modify as you like,


Eddie


 All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


The author does not use AI engines and never will.