Docsity

Elementary School - Computers and Programming I - Home Work, Lecture notes of Computer Programming

Toggle sidebar
bg1
Question 1
Computers are playing an increasing role in education. Write a program that
will help an elementary school student learn multiplication. At least, one
function should be used in your program. Use rand to produce two positive
one-digit integers. It should then type a question such as:
How much is 6 times 7?
The student then types the answer. Your program checks the student’s
answer. If it is correct, print “Very good!”, and then ask another
multiplication question. If the answer is wrong, print “No. Please try again.”
And then let the student try the same question again repeatedly until the
student finally gets it right.
Question 2
Write a program that plays the game of “guess the number” as follows:
pf2

Partial preview of the text

Download Elementary School - Computers and Programming I - Home Work and more Lecture notes Computer Programming in PDF only on Docsity!

Question 1

Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. At least, one function should be used in your program. Use rand to produce two positive one-digit integers. It should then type a question such as: How much is 6 times 7?

The student then types the answer. Your program checks the student’s answer. If it is correct, print “Very good!”, and then ask another multiplication question. If the answer is wrong, print “No. Please try again.” And then let the student try the same question again repeatedly until the student finally gets it right.

Question 2 Write a program that plays the game of “guess the number” as follows:

Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000. The program then types:

I have a number between 1 and 1000. Can you guess my number? Please type your first guess.

The player then types a first guess. The program responds with one of the following:

  1. Excellent! You guessed the number! Would you like to play again (y or n)?
  2. Too low, try again.
  3. Too high. Try again.

If the player’s guess is incorrect, your program should loop until the player finally gets the number right. Your program should keep telling the player Too high or Too low to help the player “zero in” on the correct answer. At least one function should be used in your program.