Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Python program, initially with the following code in it: import random #

ID: 3695620 • Letter: W

Question

Write a Python program, initially with the following code in it:

import random

# A sequence of assignments to generate a random problem:

a = 0

b = 0

c = 0

d = 0

e = 0

u = 0

v = 0 print( ' Problem: ({a}x + {b}) + {c}({d}x + {e}) = ? ' .format(a = a, b = b, c = c, d = d, e = e))

print( ' Answer: {u}x + {v} ' .format(u = u, v = v))

Then change the sequence of assignments in the middle so that the program, when run, creates and prints a random polynomial simplication problem. (You may need additional variables.) Your code should guarantee that all of the coeffcients in the problem are single-digit integers and that all coeffcients in the answer are positive two-digit integers.

Explanation / Answer

#!/usr/bin/python
import random
# A sequence of assignments to generate a random problem:
a = random.randrange(0,9)
b = random.randrange(0,9)
c = random.randrange(0,9)
d = random.randrange(0,9)
e = random.randrange(0,9)
u = random.randrange(10,99)
v = random.randrange(10,99)
print( ' Problem: ({a}x + {b}) + {c}({d}x + {e}) = ? ' .format(a = a, b = b, c = c, d = d, e = e))
print( ' Answer: {u}x + {v} ' .format(u = u, v = v))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote