

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Some concept of Computers and Programming I are Assign Value, Single-Subscripted Array, Class Members, Current Precision, Elementary School, Complete Program, Fibonacci Sequence, Programming Errors. Main points of this homework are: Elementary School, Computers, Increasing Role, Learn Multiplication, Elementary School Student, One-Digit Integers, Program Checks, Again Repeatedly, Program, Plays
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


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:
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.