HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to Python: Print and RepeatVariablesData Types & NumbersStringsListsConditions (if / elif / else)Loops (for / while)FunctionsOperatorsDictionariesTuples & SetsError Handling (try / except)Classes (Object-Oriented)File OperationsComments & IndentationBooleans (True / False)Lambda & map / filterModules (import)InheritanceVariable Scope
REFERENCE
📖 Overview
🖥️ Output & Input
🔢 Numbers & Math
abs()round()min() / max()sum()pow()math.sqrt()
✍️ String
📋 List
🗂️ Dictionary & Set
🔁 Condition & Loop
🧩 Function
📁 File & Error
🔄 Type & Conversion
Python›REFERENCE›Numbers & Math›round()

round()

Rounds a number to the given number of decimal places.

Syntax

round(number, digits)

Description

If the second argument isn't given, it rounds to the nearest integer. If given, it rounds to that many decimal places.

Parameters

numberThe number to round.
digits(optional)How many decimal places to keep (default 0).

Returns

The rounded number.

Example

Loading editor…

Expected output

3.14
3

When to use?

For making values like money, averages and percentages readable.

Common mistakes

  • ⚠️ round(2.5) gives 2 (banker's rounding); it doesn't always round up.

Related commands

abs()int() / float()
← abs()min() / max() →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code