Categories
coding

pseudocode assignment

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

pflynt's avatar

By pflynt

My sense of humour is absurdist, inwardly bleak, caustic and morose, self-referential, rebellious and defiant, even in some cases sadistic, but overall sincere and even in the tragedies, hopeful.

Leave a comment

Design a site like this with WordPress.com
Get started