I am new to python. I divided two numbers but, I no get decimal part.
amount = 1000
people = 3
average = total_amount/total_people
print average
I am getting o nly 333 not 333.33 How to solve this? I am ubuntu user.
I am new to python. I divided two numbers but, I no get decimal part.
amount = 1000
people = 3
average = total_amount/total_people
print average
I am getting o nly 333 not 333.33 How to solve this? I am ubuntu user.
In Python2 you should convert one of the numbers to float:
average = float(total_amount) / total_people
Another option is to use the backported division operator from Python3:
from __future__ import division
amount = 1000
people = 3
average = total_amount / total_people
print average
>> 333.333333
(This will work if you of course use the correct variable names).
amount = 1000
people = 3
average = float(amount)/float(people)
print average
OR
from __future__ import division
amount = 1000
people = 3
average = amount/people
print average