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?

26th Aug 2016, 4:28 PM
The Flash
The Flash - avatar
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
26th Aug 2016, 5:22 PM
sola
sola - avatar
+ 1
only division makes two integers to become a float...
29th Aug 2016, 8:21 PM
Ali Abolhassanzadeh Mahani
Ali Abolhassanzadeh Mahani - avatar
+ 1
4//2 will give 2 (an int) and 4/2 will give 2.0 (a float)
5th Sep 2016, 5:29 PM
Rishabh Nishad
Rishabh Nishad - avatar