0

Data type assignment

def print_sum_twice(x, y, z): print(x + y) print(x - y) print((x*y)/z) print_sum_twice(5, 8, 20) when the above block of code is ran, it prints out an int for the first two times and a float for the last one, how does python know when to treat the number as an int or a float?

19th Oct 2016, 3:05 PM
Michael Suleiman
Michael Suleiman - avatar
1 Resposta
+ 3
The result of a division with / is a float. If you want the euclidian division, use //.
19th Oct 2016, 3:27 PM
Zen
Zen - avatar