CS112: Lab 7 :: Functions, loops, and structures

Task 1. A guessing game

Write a script called lucky to play a guessing game with the user. Your loop will keep asking for guesses until the user either 1) guesses correctly or 2) quits. Your output might look something like this (in the example below, my lucky number is 14):

 
  >>lucky  
   Guess my lucky number (q to quit) ==> 2
   Nope, that's not it, guess again ==> 5
   Nope, that's not it, guess again ==> 10
   Nope, that's not it, guess again ==> 25
   Nope, that's not it, guess again ==> 100
   Nope, that's not it, guess again ==> q
  >> 
  >>lucky  
   Guess my lucky number (q to quit) ==> 18
   Nope, that's not it, guess again ==> 50
   Nope, that's not it, guess again ==> 14
   YAHOOOOO!!!!  You got it!!!
  >> 
  >>lucky  
   Guess my lucky number (q to quit) ==> 14
   YAHOOOOO!!!!  You got it!!!
  >>
 

Prelude to Assignment 5

Click here for the Assignment.

Uploading your saved work

Use Fetch to upload your saved work.
Work-in-progress should go into your personal cs112/ folder.