Title: Formatting Numbers
Slug: formatting_numbers
Summary: Formatting Numbers Using Python.
Date: 2017-02-02 12:00
Category: Python
Tags: Basics
Authors: Chris Albon
In [1]:
annual_revenue = 9282904.9282872782
In [2]:
# Format rounded to two decimal places
format(annual_revenue, '0.2f')
Out[2]:
In [3]:
# Format with commas and rounded to one decimal place
format(annual_revenue, '0,.1f')
Out[3]:
In [4]:
# Format as scientific notation
format(annual_revenue, 'e')
Out[4]:
In [5]:
# Format as scientific notation rounded to two deciminals
format(annual_revenue, '0.2E')
Out[5]: