Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (Retired) Things That Count Ints & Floats

Harsh Kumar Woike
Harsh Kumar Woike
204 Points

ints and floats

in python 3, dividing two integers give what kind of value?

2 Answers

Max Hirsh
Max Hirsh
16,773 Points

To expand on William's answer, a float is an approximate decimal number. Since dividing two integers can lead to values other than whole numbers, e.g. 2/4 = 0.5, python3 I think defaults to returning the division of two integers as a float to be consistent.

There are some programming languages that will actually round the result to the nearest integer afterwards, or raise an error when dividing an int by another int.