pseudocode assignment

Published July 20, 2018
Advertisement

The assignment was to adapt the guessing game to reverse the process,

by allowing the player to choose the number and let the computer try to guess it,

then to write this game as pseudocode.

Let me know how well you think I did?

 

declare variables

import random

def start

Print "guess cannot be higher than 50"

if number >50 then print "you cheated":break

input (low)"what is the lowest possible number your guess could be?"
input (high)"what is the highest possible number your guess could be?"
computer chooses a random number between low and high
check to see if it is the number
elif check to see if the number is too low
if so numscale=low
elif check to see if the number is too high
if so numscale=high

def new method
if the number is too low tell computer the guess is too low
if the number is too high tell the computer the guess is too high
is this the first time guessing?

if the guess is too low and this is the first time guess=guess+2
if the guess is too high and this is the first time guess=guess-2
if the guess is too low and this is not the first time guess=guess+1
if the guess is too low and this is not the first time guess=guess-1
print guess
guessCount=guessCount+1
goto start

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement