Home >Backend Development >Python Tutorial >How to keep 2 decimal places in python
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.
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
2, and then write comments for this program.
3. Create a new variable a
4. Use the round function to keep the value of a in 2 digits
5. Print the results.
6. Select "run"->"run" in the window
7.Finally run this program.
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!