Instructions
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. import random

Answer :

MrRoyal

Answer:

The original program is not given; So, I'll just write the program myself in python

import random

x = random.randint(1,10)

y = random.randint(1,10)

result = x * y

print(str(y)+" * "+str(x)+" = "+str(result))

Explanation:

The first line imports random

import random

The next two line generates random numbers between 1 and 10 and save in variables x and y

x = random.randint(1,10)

y = random.randint(1,10)

This line multiplies both numbers

result = x * y

This line prints the result

print(str(y)+" * "+str(x)+" = "+str(result))

fichoh

The modified program written in python 3 is given below :

  • import random
  • # import the random module for generating random numbers

  • a = random.randint(1, 11)
  • #a random integer value between the values (1 and 10) is attached to variable a

  • b = random.randint(1,11)
  • #a random integer value between the values (1 and 10) is attached to variable b

  • answer = a * b
  • # multiplies the value of a and b and attach the result to the variable answer

  • print(str(a) + " * " + str(b) + " = " + str(answer))
  • #displays the operation and result obtained as a string.

Learn more on python programs :https://brainly.com/question/16674303

Other Questions