print()

Lie Ryan lie.1296 at gmail.com
Sat Oct 17 17:21:11 CEST 2009


mattia wrote:
> Another question (always py3). How can I print only the first number 
> after the comma of a division?
> e.g. print(8/3) --> 2.66666666667
> I just want 2.6 (or 2.66)

Are you sure you don't want that to be 2.7 or 2.67? Then you can use:
n = int(n * 10**2) / 10**2
else if 2.7 pr 2.67 is what you wanted, you could use:
n = round(n, 2)



More information about the Python-list mailing list