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.
Good luck!
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))