6.2k views
0 votes
Hey, if anyone is familiar with python coding I would be appreciative of some troubleshooting help on some code.

I am trying to get a proper decimal response on a division question and can't get anything except 0 or 0.0 when I convert result3 to a float. My question is how do I get a PROPER decimal response on this, and thank you.
the code :
numy1=(8)
numy2=(13)
numy3=((numy2)-(numy1))
result3=(numy3)/(numy1)
print (result3)
#the proper answer should be 0.625

User Jelle Foks
by
5.5k points

1 Answer

1 vote

I downloaded your ide and it seems you just need to turn your initial numy1 and numy2 to floats.

numy1 = float(8)

numy2 = float(13)

numy3 = numy2 - numy1

result3 = numy3 / numy1

print(result3)

This will print out your desired result.

User Tony Cheetham
by
5.8k points