Monday, August 9, 2021

Numworks: Finding a Numeric Target Game

Numworks:  Finding a Numeric Target Game


Happy Monday!


Introduction


The Python script target.py is a game where the player is tasked to guess a mystery number.   The game has four levels:


Level 0:  Easy.  Range of 50, number between 100 and 999.

Level 1:  Medium.  Range of 100, number is between 1,000 and 9,999.

Level 2:  Difficult.  Range of 250, number is between 10,000 and 99,999. 

Level 3:  Challenge.  Range of 500, numbers if between 100,000 and 999,999.


After each guess you will be told whether the target is higher or lower than your guess.   At the beginning you are given a range where your target number is.


Trick:  I fit a quartic curve to the points (0,50), (1,100), (2,250), and (3,500) and Numworks came up with y = 50*x^2 + 50.   


The script page on my Numwork's account is here:  https://my.numworks.com/python/ews31415/target


Numworks Python Script: target.py


from math import *

from random import *

# 2021-08-03 EWS

# target finding game


# set up

print("**** TARGET ****")

print(" EWS 2021")

print(" ")

print("SELECT MODE")

print("0. EASY")

print("1. MEDIUM")

print("2. DIFFICULT")

print("3. CHALLENGE")

c=int(input())


# variables

# range

r=50*c**2+50

# lower limit

x=10**(c+2)

# upper limit

y=10**(c+3)-1

# score

s=0

# target, limits

t=randint(x+r,y-r)

lx=t-r

ly=t+r


# the game

g=-1

print("The target is between")

print(str(lx)+" and "+str(ly)+".")


while g!=t:

  s+=1

  g=int(input("Guess "+str(s)+"? "))

  if g>t:

    print("LOWER")

  else:

    print("HIGHER")

  

print(str(g)+" is the target!")

print("Your score is: "+str(s))


Good luck!  


Testing News


According to their website, numworks.com the Numworks calculator is now permitted for SAT, AP, PSAT, and ACT.  Click here for more information:  https://www.numworks.com/calculator/exams/

Note: Some Python Scripts can be Transferred to Different Calculators as is - Check the modules!  

You can download the Python file here.   I was able to transfer the file to a TI-84 Plus CE Python and it runs fine.  Because of the modules used, it should be able to run on any calculator with Python.  Please be aware that the calculator must have the modules installed before attempting to transfer Python scripts between different kinds of calculators.  

Link:  https://drive.google.com/file/d/1g2JjxkeKbk14Pm-qZR_LdW-0B4_BcZik/view?usp=sharing

Eddie


All original content copyright, © 2011-2021.  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. 


TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...