0
eggs = 4 spam = 5 print (eggs*spam) output = 20 but the answer must be 20.0 right? because any action on integers yields a float value?
3 odpowiedzi
+ 10
No,just by dividing (/)
4/2
2.0
but if you want a result as a float
print(float(4*5))
20.0
+ 1
only division makes two integers to become a float...
+ 1
4//2 will give 2 (an int)
and 4/2 will give 2.0 (a float)