Printing Values In Python

Introduction

 
In this article, I will explain about printing the values in Python. In previous blogs, I have explained about the Simple Strings with insert and delete. Here, I am explaining how to add the values that print on the Run module. 
 
Software requirement
 
Python 2.7.11
 
Simple program
  1. print("%f" %(4235-0.23))   
  2. print("%0.2f" % (4235-0.23))   
  3. print("%0.f" % (4235-0.23))   
Explanation
 
First, the %f is used to find the decimal point in the number. Then, %0.2f is used for displaying the two digits after the decimal. Then, the %0.f is used for not displaying the decimal values. 
 
Lets us see the difference
  1. print("%f" %(4235-0.23))   
In this statement, it will show the decimal point and the floating numbers after the decimal.
 
output
 
output
  1. print("%0.2f" % (4235-0.23))   
In this statement, it will display only two numbers after the decimal point.
 
Output
 
Output
  1. print("%0.f" % (4235-0.23))   
In this statement, it will display only the number, not the digits after the decimal point.
 
Output
 
Output
 
Final Program
 
Output
 
Final Output
 
Output