How do i round off a float value to two decimal place. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How do i round off a float value to two decimal place.

I was wondering how to round off decimal places in python. As some question i need this to be concept clear

1st Aug 2016, 5:46 AM
Y. Aakash
Y. Aakash - avatar
2 Respuestas
+ 2
you need to call the round () function. for example:let us say we have a variable name a, which has an output : 12.3469 if we want to round off to two decimal places, we say: a (round,2) we should get 12.35
1st Aug 2016, 10:52 AM
Said abdu
+ 2
just use format specifiers see below code print("%.2f" %(12.3469))
1st Aug 2016, 5:48 PM
Sagar Pohekar