I edited code here to assign variables to float. It is not working.
This code is to find value of either factor in (x+y)^2 = x^2 + 2xy + y^2
There are three factors, x, y and result. Value must be available for any two.
The only problem here is, you can't find value of x or y if they are float. For that I'm looking forward in google & to use some math's library if I can understand.
x = (input("\nEnter value of x: "))
y = (input("\nEnter value of y: "))
z = (input("\nEnter value of (x+y)^2: "))
#-----------------------------------------------------------------------
#Converting input to integers.
#-----------------------------------------------------------------------
a=0.0
b=0.0
c=0.0
if len(x)!=0:
a = float(x)
else:
print ("\nWe will search value of 'x'")
if len(y)!=0:
b = float(y)
else:
print ("\nWe will search value of 'y'")
if len(z)!=0:
c = float(z)
else:
print ("\nWe will search value of '(x+y)^2'")
#-----------------------------------------------------------------------
#Calculations
#-----------------------------------------------------------------------
from math import sqrt
fv=0.0 #fv = find value
rs=0.0 #rs = result
if len(x)==0:
while True:
rs = ((fv*fv) + (2*fv*b) + (b*b))
fv = fv + 1
if rs==c:
print (f"\nValue of 'x' is either {(fv-1)} or {((sqrt(c)*-1) - b)}")
break
if len(y)==0:
while True:
rs = ((a*a) + (2*a*fv) + (fv*fv))
fv = fv+1
if rs==c:
print (f"\nValue of 'y' is either {(fv-1)} or {((sqrt(c)*-1) - a)}")
break
if len(z)==0:
rs = ((a*a) + (2*a*b) + (b*b))
print (f"\nValue of '(x+y)^2' is {rs}")
print ("\nThank you")