4.6 - Pseudocode

Review

  • Planning is crucial. Even if you don't like it - do it!

  • Storyboards and flowcharts are only two examples of many planning tools.

4.6 - Pseudocode


  • Written in a more human-readable format.

  • Follow indenting and whitespace rules of code.

  • Generalization of algorithm - not language specific


Example: The Infinite Guessing Game

Always keep in mind that there may be more than one way to complete a task.

secret random number from 1 to 20
userGuess ""
guesses 0

Inform the user of the rules

WHILE userGuess not equal to secret
userGuess "Please make a guess from 1 to 20"
guesses guesses + 1
IF userGuess less than secret
"Your guess was too low"
ELSE IF userGuess greater than secret
"Your guess was too high"


"Congrats! You guessed it in {guesses} guesses"


Your turn!

Get together with your partner (if you have one) for the RPSLS game. Write out the pseudocode for the main portion of the game. Utilize your flowchart from 4.5 to assist you.