+ 1

(edited) I want the code to choose 2 numbers such that their product is 4 and sum is 3

cdd = range(12) for i in cdd: for j in cdd: if i*j == 4 and i+j == 3: print(i,j)

13th Oct 2020, 7:30 AM
Okwach Kich
Okwach Kich - avatar
3 odpowiedzi
+ 4
i don’t think that this equation is possible i + j=3 i=3-j i*j=4 j(3-j)= 4 (substituting the value of j) 3j-j^2=4 j^2-3j+4=0 here, b^2 - 4ac is negative so this equation doesn’t have any real solution
13th Oct 2020, 7:58 AM
Ren
+ 1
what output do you want?
13th Oct 2020, 7:38 AM
Ren
0
Look at it as attempt to solve the quadratic equation (x^2)+3x+4=0
13th Oct 2020, 8:04 AM
Okwach Kich
Okwach Kich - avatar