1 Replies - 5578 Views - Last Post: 16 September 2012 - 11:52 PM Rate Topic: -----

#1 beltway   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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:
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?
What is 1 x 4?
What is 6 x 10?
What is 5 x 10?
What is 10 x 2?
What is 3 x 9?
Sorry, the answer is 27.
What is 5 x 7?
You got 83.3% of the problems.

I have this so far...


import random

def main():


    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("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   User is offline

  • New D.I.C Head

Reputation: 12
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1