Jump to page content Jump to navigation

College Board

AP Central

APAC 2009 Call For Proposals
AP Course Audit Web Site


Siemens Awards for Advanced Placement
Print Page
Home > AP Courses and Exams > Course Home Pages > Guessing Game

Guessing Game

by Rodney Hoffman
Occidental College
Los Angeles, California

More Nifty Assignments...

Assignment
Have your program pick a random integer between 1 and 100 (and keep it "to itself"). When you run the program, you try to guess the number. The program tells you whether your guess is too high, too low, or exactly right. If you don't guess the number within a certain number of tries, the program should tell you that you lost the game and tell you what the hidden number was. Be sure the program gives good instructions when it begins.

Teacher's Comments
If you want to give your students more of a challenge, try the following add-on later in the course.

Binary Search
Redo the "guess the number from 1 to 100" game with the roles reversed. This time, the person playing the game thinks of a number, and your program tries to guess it. Give good and complete instructions and prompts.

Contribute
If you would like to contribute your suggestions for nifty assignments, please submit your ideas.


  ABOUT MY AP CENTRAL
    Course and Email Newsletter Preferences
  AP COURSES AND EXAMS
    Course Home Pages
    Course Descriptions
    The Course Audit
    Sample Syllabi
    Teachers' Resources
    Exam Calendar and Fees
    Exam Questions
    AP Credit Policy Information
  PRE-AP
    Teachers' Corner
    Publications
  AP COMMUNITY
    About Electronic Discussion Groups
    Become an AP Exam Reader

Back to top