x : Input number .
n :(optional ) Input number of digits after decimal .
Returns float or integer after rounding the input number upto the given decimal.
print(round(12.34567))     # 12
print(round(-12.34567))    # -12
print(round(12))           # 12
print(round(-12))          # -12
print(round(12.34567,2))   # 12.35
print(round(-12.34567,3))  # -12.346
To get better precision, decimal module can be used. Check this line. Expected output is not 3.68
print(round(3.675,2)) # 3.67 

Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 All rights reserved worldwide Privacy Policy Disclaimer