Search for '{{search_term}}'

Exercise: Number guessing game

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

In this exercise we are starting to build a game, called the number guessing game.

The game is that the computer "thinks" about a number and we have to guess it. On every guess, the computer will tell us if our guess was smaller or bigger than the hidden number. The game ends when we find the number.

This exercise is the first step of this game.

Create a simple command line game guessing a whole number.

  1. Let the computer "think" about a whole number between 1-200.
  2. Let the user guess a number.
  3. Tell the user if his guess was bigger or smaller than the number the computer "thought" of or tell them if they hit the right number.
  4. At this point the user only has one guess, though as a bounus you can allow the user to guess several times.



In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus