In this article, we will learn to write python program to print float value using built-in methods –
Above program shows a flow how built-in methods are used to print float value.
In this article, we will be used below methods
Method 1: Using print() method
We can use print() method to print float value as shown below –
a = input("Enter a value:") print("Entered value: ", a)
Using print() method, we are printing value to console.
Run program, output is –
Enter a value: 45.98 Entered value: 45.98
Method 2: Using sys.stdout.write() method to Print Float Value
Below is a sample program to show how can we print float value in python using built-in method. Here, we have used sys.stdout.write method() to print value.
import sys a = input("Enter a float value:") sys.stdout.write("Entered value is: " + a)
In Above program, we have used write() method present inside sys.stdout module in python.
When you run above program, output is –
Enter a float value: 12.9 Entered value is: 12.9
That’s how we can write program to print float value.