37.4k views
3 votes
Currently, this program will add 6 and 3 together, output the math problem and output the answer. Edit this code so that a random number is generated from 1 - 10 (inclusive) for the variables a and b. Also, instead of adding the two numbers together, the edited program should multiply them, and output the proper math problem and answer. Be sure to update every line of code to reflect the changes needed.

2 Answers

5 votes

In python:

import random

a = random.randint(1,10)

b = random.randint(1,10)

print(f"{a} * {b} = {a * b}")

I hope this helps!

User Marco Merola
by
5.4k points
3 votes

Answer:

import random

a = random.randint(1,10)

b = random.randint(1,10)

answer = a * b

print (str(a) + " * " + str(b) + " = " + str(answer))

Step-by-step explanation:

Create a code that outputs a random equation then solves it automatically ^

User Daniel Pittman
by
5.3k points