Home  >  Article  >  Backend Development  >  How to keep 2 decimal places in python

How to keep 2 decimal places in python

coldplay.xixi
coldplay.xixiOriginal
2021-01-19 16:36:18154632browse

How to retain 2 decimal places in Python: First open the editor pycharm and create a new variable a; then use the round function to retain the value of a with 2 digits and print the result; then select "run" in the window; Finally, run this program.

How to keep 2 decimal places in python

The operating environment of this tutorial: windows7 system, pycharm2020 version, DELL G3 computer. This method is suitable for all brands of computers.

Related free learning recommendations: python video tutorial

Python method of retaining 2 decimal places:

1. First open the python editor pycharm

How to keep 2 decimal places in python

2, and then write comments for this program.

How to keep 2 decimal places in python

3. Create a new variable a

How to keep 2 decimal places in python

4. Use the round function to keep the value of a in 2 digits

How to keep 2 decimal places in python

5. Print the results.

How to keep 2 decimal places in python

6. Select "run"->"run" in the window

How to keep 2 decimal places in python

7.Finally run this program.

How to keep 2 decimal places in python

A large number of free learning recommendations, please visit python tutorial(video)

The above is the detailed content of How to keep 2 decimal places in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn