+ 1

Python Confusion

I'm doing the Python course and am on Simple Operations. I might sound idiotic but I don't understand about the output of numbers, why is it that I saw sometimes the output would be without a decimal and another ending up as 9.0 Is this because of the division?

17th Nov 2016, 8:36 PM
DreamANight
DreamANight - avatar
3 ответов
+ 5
just a small tip use // instead of / to divide and only take integer print(7/2) 3.5 print(7//2) 3 print(4/2) 2.0 print(4//2) 2
17th Nov 2016, 9:41 PM
Burey
Burey - avatar
+ 4
division in python normally gives a float in other terms number with decimal.i hope am clear
17th Nov 2016, 8:40 PM
masterchief
0
Thank you, that quickly clears up my confusion.
17th Nov 2016, 8:43 PM
DreamANight
DreamANight - avatar