Round up the number to 2 decimal places.

In this python if else program, we will round up the number to 2 decimal places if the number is a float.

Float number:
A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed.

Steps to solve the program
  1. Take a number as input.
  2. Using an if-else statement check the type of the number using type().
  3. If the type of the number is a float then round up the number to 2 decimal places using the round() function.
  4. Else print the number as it.
				
					num = 25.3614

if type(num) == float:
    print(round(num,2))
else:
    print(num)
				
			

Output :

				
					25.36
				
			

Related Articles

reads month and returns season for that month.

check whether the input number is divisible by 12 or not.

Leave a Comment