Write a function that takes as a parameter an integer (as a long valu.docx
Guess a number game
1. Data Dictionary
Name Data Type* Usage** Initial
Value/Range
Description
again string input y or Y To control the while loop
count int constant 0 To holdthe numberof guesses
guess int input 1-20 Holdthe usersguess
name string input ------------------ Holdthe usersname
number int constant 1-20 Randomnumberfunction
*Data Type – integer,floatingpoint,string,Boolean
**Usage – input,output,calculation,constant
Test Data
Set Number** NUMBER Guess Results
1 random 3 To Low
2 random 20 To High
3 random 8 To High
4 random 17 To High
5 random 4 To Low
6 random 7 Good Job
1 random 7 To Low
2 random 9 To Low
3 random 11 To Low
4 random 13 To Low
5 random 14 To Low
6 random 18 You failedtoguest
my numberinsix
guesses
*one columnneededforeachvariable usedinthe programom
**minimumof 3 setsof testdata
Pseudocode
What followsisabasictemplate formostprograms
Declare constants
number= random.randint(1, 20)
2. Declare variables
again= y or Y
guess
name
Get input
Hello!Whatisyour name?
While guess<1 or guess> 20
Invalidinputpleaseenteranumberbetween1and20
While again== ‘y’ or again== ‘Y’:
Well,Name,I’mthinkingof a numberbetween1and 20?
Take a Guess
Performprocessing
Count= 1
While count< 6:
Count= count+ 1
If guess== number
Count= count- 1
Congratulationsyouguessthe numberinnumberof attemptsguesses
If guess > number
Guessto high
Take a guess
If guess< number
Guessto low
Take a Guess
While guess!=number
Displayoutput
Display Congratulationsyouguessthe numberincounterguesses
3. Display
Guessto high
Take a guess
Display
Guessto low
Take a guess
Display
You failedtoguestmynumberinsix guesses
Wouldyoulike toplayagain Y/N