Well I am having trouble to print numbers with decimal point.
When I run python and ask it to do a division, in which the result must be a number with decimal point, it doesn’t print the decimal point.
For instance, I have just made this algorithm:
print 'Report card calculation'
grade1 = input ('Insert the first grade: ')
grade2 = input ('Insert the second grade: ')
grade3 = input ('Insrt the third grade: ')
media = (grade1 + grade2 + grade3) / 3
print 'Your final result is', media
But when it prints the “media”, the number which should have a decimal point doesn’t come with a decimal point. How can I fix it?
Simplest change: divide by
3.0instead of3:This will ensure that the value assigned to
mediawill be floating point even if the three grade variables hold ints.