Def function not returning a floating point number

I am having a probem with my def function not returning a floating point number. On my computer when I run this instead of getting 2.5 I get 2 does anyone know what the problem is?

def code(a,b):
ans = a / b
print “%d” % ans
return ans

num = 50.
num1 = 20.

answer = code(num, num1)

print “%d / %d = %d” % (num, num1, answer)

Wrong conversion specifier: %d prints an integer. Try %f.

2 Likes