Find 2 numbers that multiply to a number and add to another number
Code Review

while solved == False: is an awkward way of writing the loop condition.  while not solved: would be clearer and more Pythonic.



You never set solved = True anywhere.  Instead, you unconditionally break out of the loop.  This means your loop could actually be written while True:, but I don't think this is clearer.  Using solved = True instead of break would terminate the loop in an expected way.



This is verbose:

    nums = random.sample(range(-100, 150), 2)
    if (nums[0] + nums[1] == add_to) and (nums[0] * nums[1] == multiply_to):


You could unpack nums into to individual variables, and avoid the [0] and [1] indexing operations, for more performant code:

    x1, x2 = random.sample(range(-100, 150), 2)
    if x1 + x2 == add_to and x1 * x2 == multiply_to:




If you give values which can never work with integers, like add to 2 and multiply to 3, you have an infinite loop.  You should have a "give up after so many attempts" procedure.



Monte Carlo

As pointed out by Peilonrayz, there is an \$O(1)\$ solution to the problem.

However, if your goal is to utilize a Monte Carlo simulation method ...

If multiply_to is:


positive, then the numbers must be the same sign, both positive or both negative, which you could determine by looking at the add_to sign,
negative, then one number must be greater than zero, and the other must be less than zero,
zero, then one number must be zero.


eg)

if multiply_to &gt; 0:
    if add_to &gt; 0:
        r1 = range(1, add_to)
        r2 = range(1, add_to)
    else:
        r1 = range(add_to + 1, 0)
        r2 = range(add_to + 1, 0)

elif multiply_to &lt; 0:
    r1 = range(1, 150)   # A positive value in your initial range bracket
    r2 = range(-100, 0)  # A negative value in your initial range bracket

else:
    r1 = range(add_to, add_to + 1)
    r2 = range(0, 1)


for _ in range(10_000):
    x1 = random.choice(r1)
    x2 = random.choice(r2)
    if x1 + x2 == add_to and x1 * x2 == multiply_to:
        print(f"Solved: {x1} + {x2} = {add_to}, {x1} * {x2} = {multiply_to}")
        break
else:
    print("Couldn't find a solution")