Click here to Skip to main content
15,886,078 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
how to round results to 2 decimal places?

What I have tried:

p=10

l=5

a=0





distance = [ ]

distance.append(0)

for n in range(0,p):

a +=(l/p)*2.9

distance.append(a)

print('distance = ',distance)
Posted
Updated 26-Jul-22 6:00am
Comments
0x01AA 26-Jul-22 12:00pm    
Like this: Python round()[^]

1 solution

You need to use string formatting to get values printed in specific forms: formatstrings — Common string operations — Python 3.10.5 documentation[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900