Round Number in Python

Level 117 keystrokes

This rounds 3.7 to the nearest integer and prints 4. The round() function returns the closest whole number.

Python code

# round() rounds a number to the nearest integer
# 3.7 is closer to 4 than to 3, so 4 is printed
1print(round(3.7))

Output

4
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • (× 2
  • )× 2
  • .× 1

More Python examples at level 1

← Python typing practice