w3resource

Python Math: Print number with commas as thousands separators

Python Math: Exercise-26 with Solution

Write a Python program to print number with commas as thousands separators (from right side).

Sample Solution:-

Python Code:

print("{:,}".format(1000000))
print("{:,}".format(10000))

Sample Output:

1,000,000                                                                                                     
10,000

Pictorial Presentation:

Python Math: Print number with commas as thousands separators

Flowchart:

Flowchart: Print number with commas as thousands separators

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program for nth Catalan Number.
Next: Write a Python program to calculate distance between two points using latitude and longitude.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Share this Tutorial / Exercise on : Facebook and Twitter

Python: Tips of the Day

Lambdas for Sorting:

>>> students = [{'name': 'John', 'score': 98}, {'name': 'Mike', 'score': 94}, {'name': 'Jennifer', 'score': 99}]
>>> sorted(students, key=lambda x: x['score'])
[{'name': 'Mike', 'score': 94}, {'name': 'John', 'score': 98}, {'name': 'Jennifer', 'score': 99}]