0

Why we add 0 in the end

Why (8+4)/2 the answer is 6.0 can't we print 6

18th Nov 2016, 10:36 AM
Chris
2 ответов
+ 1
12//2=6 (integer division) 12/2=6.0 (automatic convert to floating point)
18th Nov 2016, 10:55 AM
Marcell Juhasz
0
python 3 should automatically print the code as 6, you can however define the sum as an int before you print it i.e. n = int(8+3)/2 print(n) this would print "6" similarly you can use float as such: n = float((8+2)/2) print(n) this would print 6.0
18th Nov 2016, 8:03 PM
Daryl 'Baz' Liney
Daryl 'Baz' Liney - avatar