Floating numbers up to 3 decimal places.

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
  1. Take a floating number as input.
  2. Create an empty string.
  3. Use the round() function to round up the given floating number up to 3 decimal places.
  4. Conver rounded number to a string using str() and add it to the empty string.
  5. Print thee output.
				
					#Input string
num = 2.14652
result = ""

#Rounding number
result += str(round(num, 3))

#Printing output
print(result)
				
			

Output :

				
					2.147
				
			

split and join a string

convert numeric words to numbers.

Leave a Comment