April 20, 2014

Homework Help: Computers (Programming by Python)

Posted by Jaizzer on Wednesday, September 19, 2012 at 7:47am.

Problem 1:
Multiplication Drill
Computers can perform calculations extremely quickly and accurately, but it's often handy to calculate with the computers we carry around inside our heads.

Write a program to drill you in multiplication tables. Your program should read a single line of input containing an integer, and print out the multiples of that number up to 12 times that number.

Here is an example interactive session between your program and a user:
Enter a number: 3

3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
3 x 11 = 33
3 x 12 = 36

Problem 2:

You have always wanted to visit the Pyramids of Giza but unfortunately you've got too much homework to do!

To try and help with your travel withdrawals, you decide to write a program to generate pyramids for you. ASCII art pyramids are the next best thing, right?

Write a Python program to read in the width of the pyramid. Your program should then print out a pyramid using asterisks. For example:

Enter width: 2
* *

Problem 3:

Simon Says

Simon Says is a children’s game in which a leader gives instructions in the form of "Simon says put your hands in the air" and the players have to do what they say. However, if the leader gives an instruction without starting with 'Simon says' the players do nothing.

Write a program that plays this game. It should read in lines of input until a blank line is entered. If the line starts with Simon says it should print out the rest of the line. Lines that do not start with Simon says should be ignored.

Here is an example interaction between your program and the user:

Enter: jump
Enter: Simon says shout loudly
shout loudly
Enter: Simon would like you to eat a frog
Enter: Simon says clap your hands
clap your hands

Problem 4:
Meaning of Life - What is the meaning of life? This hotly debated and philosophised question has existed since the dawn of time. If you've read The Hitchhiker's Guide to the Galaxy, then you'll know that the answer to the ultimate question of life, the universe, and everything is 42.

Write a program to ask the user What is the meaning of life?. Your program should keep asking the user this question until the user answers 42. Each time the user enters something that is not 42, your program should print out Incorrect.

You should keep track of the number of attempts it took the user to guess 42. After the user finally guesses 42, your program should output You got it in X attempt(s)!, where X is the number of attempts made. So, for example:

What is the meaning of life? To be a good person
What is the meaning of life? To play monopoly
What is the meaning of life? 42
You got it in 3 attempt(s)!

Here is another example:
What is the meaning of life? 42
You got it in 1 attempt(s)!
Problem 5:

Sequel Rating

You love a movie, but is it worth watching its sequel? If the rating it gets online is better or the same, then you might like to watch it.

You should write a Python program to ask the user for two ratings; the rating of the original movie and the rating of the sequel. Your program should then announce either that The sequel is worth it! or Give it a miss..

If the rating of the sequel is less than that of the original, your program should output Give it a miss.. Otherwise, it should output The sequel is worth it!

For example:

Enter the original rating: 90
Enter the sequel rating: 100
The sequel is worth it!

Here is another example:

Enter the original rating: 50
Enter the sequel rating: 10
Give it a miss.

Answer this Question

First Name:
School Subject:

Related Questions

5th grade math - Could someone explain what multiplication comparisons are? An ...
Computer (Programming with Python) - Problem 1: Multiplication Drill Computers ...
Teachers Aide/Technology in the Classroom - Which of the following scenarios ...
computers - what computers can do?what computers cannot do?what are the ...
math - Julius sold 5x as many computers as Sam sold last year. In total they ...
math help - Universal instruments found that the monthly demand for its new line...
Calculus - Universal instruments found that the monthly demand for its new line ...
computers - which set of terms below correctly pairs a generation of computers ...
computers - How can i tell python to stop printing something after a specific ...
math/computers - Problem: Solve X mod Y for all positive integers. Do so without...