As you are talking about trailing zeros, this is a question about representation as string, you can use

>>> "%.2f" % round(2606.89579999999, 2)
'2606.90'

Or use modern style with format function:

>>> '{:.2f}'.format(round(2606.89579999999, 2))
'2606.90'

and remove point with replace or translate (_ refers to result of previous command in python console):

>>> _.translate(None, '.')
'260690'

Note that rounding is not needed here, as .2f format applies the same rounding:

>>> "%.2f" % 2606.89579999999
'2606.90'

But as you mentioned excel, you probably would opt to roll your own rounding function, or use decimal, as float.round can lead to strange results due to float representation:

>>> round(2.675, 2)
2.67
>>> round(2606.89579999999, 2)
2606.89

With decimal use quantize:

>>> from decimal import *
>>> x = Decimal('2606.8950000000001')
# Decimal('2606.8950000000001')
>>> '{}'.format(x.quantize(Decimal('.01'), rounding=ROUND_HALF_EVEN))
'2606.90'

That, for your original task, becomes:

>>> x = Decimal('2606.8950000000001')
>>> int((x*100).quantize(1, rounding=ROUND_HALF_EVEN))
260690

And the reason of strange rounding comes to the front with Decimal:

>>> x = Decimal(2606.8950000000001)
# Decimal('2606.89499999999998181010596454143524169921875') # internal float repr
Answer from alko on Stack Overflow
Top answer
1 of 6
96

As you are talking about trailing zeros, this is a question about representation as string, you can use

>>> "%.2f" % round(2606.89579999999, 2)
'2606.90'

Or use modern style with format function:

>>> '{:.2f}'.format(round(2606.89579999999, 2))
'2606.90'

and remove point with replace or translate (_ refers to result of previous command in python console):

>>> _.translate(None, '.')
'260690'

Note that rounding is not needed here, as .2f format applies the same rounding:

>>> "%.2f" % 2606.89579999999
'2606.90'

But as you mentioned excel, you probably would opt to roll your own rounding function, or use decimal, as float.round can lead to strange results due to float representation:

>>> round(2.675, 2)
2.67
>>> round(2606.89579999999, 2)
2606.89

With decimal use quantize:

>>> from decimal import *
>>> x = Decimal('2606.8950000000001')
# Decimal('2606.8950000000001')
>>> '{}'.format(x.quantize(Decimal('.01'), rounding=ROUND_HALF_EVEN))
'2606.90'

That, for your original task, becomes:

>>> x = Decimal('2606.8950000000001')
>>> int((x*100).quantize(1, rounding=ROUND_HALF_EVEN))
260690

And the reason of strange rounding comes to the front with Decimal:

>>> x = Decimal(2606.8950000000001)
# Decimal('2606.89499999999998181010596454143524169921875') # internal float repr
2 of 6
30

As of Python 3.6, you can also use an f-string to inline format the number. In this case, the desired format is floating point with 2 decimal places so you would use .2f as the format specifier:

x = 2606.89579999999
x = round(x, 2)      # not strictly necessary as format will round for you
print(f'{x:.2f}')

Output:

2606.90
🌐
Sololearn
sololearn.com › en › Discuss › 3288381 › how-to-round-to-2-decimal-places-in-python
How to round to 2 decimal places in python | Sololearn: Learn to code for FREE!
Yes, you can use the round() function in Python to round a float to a specific number of decimal places. In your case, you can use round(number, 2) to round the number to 2 decimal places.
🌐
DataCamp
datacamp.com › tutorial › python-round-to-two-decimal-places
How to Round to 2 Decimal Places in Python | DataCamp
August 8, 2024 - Learn how to round a number to 2 decimal places in Python for improved precision using techniques like round(), format(), and string formatting techniques.
🌐
Python
docs.python.org › 3 › library › decimal.html
decimal — Decimal fixed-point and floating-point arithmetic
This has the same semantics as the unary plus operation, except that if the final result is finite it is reduced to its simplest form, with all trailing zeros removed and its sign preserved. That is, while the coefficient is non-zero and a multiple of ten the coefficient is divided by ten and the exponent is incremented by 1. Otherwise (the coefficient is zero) the exponent is set to 0. In all cases the sign is unchanged. For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize to the equivalent value Decimal('32.1'). Note that rounding is applied before reducing to simplest form.
🌐
Replit
replit.com › home › discover › how to round to 2 decimal places in python
How to round to 2 decimal places in Python
The solution is to bypass round() for display and use an f-string with the :.2f format specifier instead. This approach formats the number as a string with exactly two decimal places, adding trailing zeros where necessary.
🌐
Stack Overflow
stackoverflow.com › questions › 76451953 › rounding-numbers-to-2-decimal-places-using-round-type
python - Rounding numbers to 2 decimal places using round type - Stack Overflow
The round() function in Python follows the standard rounding rules, where trailing zeros after the decimal point are not displayed by default.
🌐
TutorialsPoint
tutorialspoint.com › How-to-round-down-to-2-decimals-a-float-using-Python
How to round down to 2 decimals a float using Python?
Round the number upto 2 digits (here 2 decimal palace . hence we give 2 zeros after the decimal point) after the decimal point using the value.quantize(decimal.Decimal()) function. ... Print the rounded value of the input number upto the 2 decimal places.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › how to eliminate trailing zeros?
r/learnpython on Reddit: How to eliminate trailing zeros?
October 3, 2019 -

I have a float formatted to 2 decimal places. I need to eliminate the 2nd decimal place if it's a "0" but still keep 2 decimal places open for when its 2 whole numbers.

number = float(25.20458)
    print(format(number, ".2f"))
#Comes out as 25.20
#Need 25.2

Windows 10 and Python 3.7

🌐
Codecademy
codecademy.com › article › rounding-to-two-decimal-places-in-pythonn
Rounding to Two Decimal Places in Python | Codecademy
One of the features of Python’s round() function is its implementation of “round half to even,” also known as “**banker’s rounding.**” In this method, a number is rounded to the nearest even number when it is exactly halfway between ...
🌐
Analytics Vidhya
analyticsvidhya.com › home › 6 ways to round floating value to two decimals in python
6 Ways to Round Floating Value to Two Decimals in Python
November 4, 2024 - When using .2f, the number will be rounded to two decimal places and displayed with two digits after the decimal point. If the number has fewer than two decimal places, it will be padded with zeros.By using .2f, you can easily format floating-point numbers to a specific number of decimal places in Python.
🌐
Python Forum
python-forum.io › thread-7788.html
Controlling trailing zeros with rounding?
I'm trying to print out floats in currency format, but no matter what numbers I specify for rounding parameters, it only prints out one 0 after the decimal point: #!/usr/bin/env python3 #FormattingStuff.py def listOfFloats(): floatsList = [20.00...
🌐
Real Python
realpython.com › python-rounding
How to Round Numbers in Python – Real Python
December 7, 2024 - >>> from rounding import round_half_down, round_half_up >>> round_half_up(1.5) 2.0 >>> round_half_up(-1.5) -1.0 >>> round_half_down(1.5) 1.0 >>> round_half_down(-1.5) -2.0 · One way to introduce symmetry is to always round a tie away from zero. The following table illustrates how this works: To implement the rounding half away from zero strategy on a number n, you start as usual by shifting the decimal point to the right a given number of places.
🌐
PythonHow
pythonhow.com › how › limit-floats-to-two-decimal-points
Here is how to limit floats to two decimal points in Python
In this case, the float x is rounded to two decimal points, resulting in the value 3.14.Alternatively, you can use the format function to format a float as a string with a fixed number of decimal points. Here is an example of how to use format to limit a float to two decimal points: x = 3.14159265 # Format x as a string with two decimal points y = "{:.2f...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-round-floating-value-to-two-decimals-in-python
How to Round Floating Value to Two Decimals in Python - GeeksforGeeks
July 23, 2025 - In Python, we can use the decimal module to round floating-point numbers to a specific number of decimal places with higher precision and control compared to the built-in floating-point arithmetic. ... from decimal import Decimal, getcontext, ROUND_HALF_UP # Step 1: Create a Decimal object from a floating-point number n1 = Decimal('123.4567') # Step 2: Define the rounding context # '0.01' specifies that we want to round to two decimal places n2 = n1.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP) print(n2)
🌐
freeCodeCamp
freecodecamp.org › news › how-to-round-to-2-decimal-places-in-python
How to Round to 2 Decimal Places in Python
August 22, 2022 - Or you can put it as rounding up 24.89 to the nearest tenth. The number 8 is at the 1 decimal place, and the number after 8 is 9.
🌐
Reddit
reddit.com › r/learnpython › how do i get numpy.round to display trailing zeros?
r/learnpython on Reddit: How do I get numpy.round to display trailing zeros?
March 9, 2023 -

Is this possible? I need to display 2 decimal points, even if both numbers are zeros. I've tried the {:0.2f}.format method but get an error that numpy doesn't work with strings.

This is my current code and output.

print("Observed Prices: ",np.round(y_test_1[0:10],2))
print("Estimated Prices:",np.round(test_pred_1[0:10],2))

Observed Prices: [33 45 54 38 22 47 38 51 46 47]

Estimated Prices: [19. 20. 24. 21. 21. 21. 18. 22. 23. 20.]

🌐
Derludditus
derludditus.github.io › ClaudePython › how-to-round-to-2-decimal-places-in-python.html
How to round to 2 decimal places in Python
Pay special attention when processing ... the number you want to round and the number of decimal places. To round to exactly 2 decimal places, use round(number, 2). This tells Python to keep precisely two digits after the decimal point....
🌐
Studytonight
studytonight.com › python-howtos › how-to-round-floating-value-to-two-decimals-in-python
How to Round Floating Value to Two Decimals in Python - Studytonight
#import decimal from decimal import getcontext, Decimal # Set the precision getcontext().prec = 3 # Execute 1/7, however cast both numbers as decimals result = Decimal(16.0)/Decimal(7) # Your output will return w/ 6 decimal places print(result) ... This precision takes the total number of digits to be printed. If prec = 2, then the output would be 2.3.