# multiplication problem

Page 1 of 1

## 1 Replies - 4085 Views - Last Post: 16 September 2012 - 11:52 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=292084&amp;s=bf46401a8b5bc22ed434900eafcbbc76&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 beltway

• New D.I.C Head

Reputation: 0
• Posts: 2
• Joined: 14-September 12

# multiplication problem

Posted 15 September 2012 - 06:24 PM

I was wondering if you can help with my python homework? I am having trouble how to solve the problem and show it. The homework problem is....

Write a program that allows the user to practice multiplication. Ask the user how many problems they want and then give the user that many problems. Each number in the problem should be in between 1 and 10, inclusive. For each question, determine if the user got the question correct. At the end of the game print out the percentage of problems they got correctly, rounded to the nearest tenth of a percent. After each question, print out a message with one of the two following formats, depending on whether or not the user correctly answered the question (where X represents the correct answer to the question:
Correct!
Sorry, the answer is X.

This is how the answer for the problem such come out...

Sample Program Run:

How many problems do you want?
6
What is 1 x 4?
4
Correct!
What is 6 x 10?
60
Correct!
What is 5 x 10?
50
Correct!
What is 10 x 2?
20
Correct!
What is 3 x 9?
24
Sorry, the answer is 27.
What is 5 x 7?
35
Correct!
You got 83.3% of the problems.

I have this so far...

```

import random

def main():

random.seed()

Varibale_1 = random.radint (1,10)
Variable_2 = random.radint (1,10)

# Get the user input.
problems_want = int(input("How many problems do you want?\n"))

# Calculate the correct answer for the problem.
product = int(input("What is"+str(Variable_1)+" x "+str(Variable_2)+"?")
problem_answer =  Variable_1 * Variable_2

If  product = problem_answer:
print("Corret!")
else:
print("Sorry, the answer is",,".",sep="")

average =
print("You got","%.1f"%average,"of the problems.")

```

Is This A Good Question/Topic? 0

## Replies To: multiplication problem

### #2 Arceopteryx

• New D.I.C Head

Reputation: 12
• Posts: 40
• Joined: 14-September 07

## Re: multiplication problem

Posted 16 September 2012 - 11:52 PM

Use a loop to print out the "multiplication problems", where the amount of "problems" that the user want, is the length of the loop.