In this program, we will take a number as input and print floating numbers up to 3 decimal places, and convert the number to a string.
Steps to solve the program
- Take a floating number as input.
- Create an empty string.
- Use the round() function to round up the given floating number up to 3 decimal places.
- Conver rounded number to a string using str() and add it to the empty string.
- Print thee output.
#Input string
num = 2.14652
result = ""
#Rounding number
result += str(round(num, 3))
#Printing output
print(result)
Output :
2.147