Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help rounding
#1
How do I round the float in last line to 2 places = x.xx instead of x.xxxxxxxxxx
it won't do it most of the time but it will with certain entered combinations.
round(n,2), or other variations did not work.

for n in range (0,items,1):
print("\t\t\t",(list1[n]),end = "\t\t\t\t")
print((float(list1[n]) * ratio),("\t"),list2[n]) line 6 float to 2 places in (floatlis[n]*ratio) I need help here

thanks for any help, Joseph
Reply


Messages In This Thread
need help rounding - by joseph202020 - Feb-21-2023, 06:23 AM
RE: need help rounding - by paul18fr - Feb-21-2023, 07:16 AM
RE: need help rounding - by jefsummers - Feb-21-2023, 01:04 PM
RE: need help rounding - by hanksbrad - Feb-21-2023, 03:29 PM
RE: need help rounding - by joseph202020 - Feb-21-2023, 08:11 PM
RE: need help rounding - by snippsat - Feb-21-2023, 04:17 PM
RE: need help rounding - by deanhystad - Feb-21-2023, 04:38 PM
RE: need help rounding - by joseph202020 - Feb-21-2023, 08:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  from numpy array to csv - rounding SchroedingersLion 6 2,410 Nov-14-2022, 09:09 PM
Last Post: deanhystad
  Random data generation sum to 1 by rounding juniorcoder 9 3,636 Oct-20-2021, 03:36 PM
Last Post: deanhystad
  Rounding issue kmll 1 1,491 Oct-08-2021, 10:35 AM
Last Post: Yoriz
  Not rounding to desired decimal places? pprod 2 2,637 Mar-05-2021, 11:11 AM
Last Post: pprod
  Decimal Rounding error project_science 4 2,862 Jan-06-2021, 03:14 PM
Last Post: project_science
  rounding and floats Than999 2 3,232 Oct-26-2020, 09:36 PM
Last Post: deanhystad
  Rounding to the nearest eight wallgraffiti 2 2,174 Jul-15-2020, 06:05 PM
Last Post: wallgraffiti
  rounding question DPaul 16 5,889 Apr-12-2020, 02:30 PM
Last Post: DPaul
  price + tax rounding mlieqo 11 6,691 Sep-21-2019, 04:53 PM
Last Post: mlieqo
  rounding floats to a number of bits Skaperen 2 2,387 Sep-13-2019, 04:37 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020