0

How do you round up floats in python

Guys I've read that round() is a built-in function in python, but it gives me no output when I use to round up floats. Is there any other way of rounding up numbers without using round()?

14th Jul 2022, 9:44 AM
Magadjiya
Magadjiya - avatar
4 Antworten
+ 5
Did you print result ? Seems you didn't...! edit: Khadija check these print( round(23.67)) x = 7.22818 print( round(x)) print( round(12.2168, 2) )
14th Jul 2022, 9:51 AM
Jayakrishna 🇮🇳
+ 2
Can you show your try ? and expected output ! ex: print(round(0.97)) #1.0 print(round(0.947,2)) #0.95 print(round(0.947,1)) #0.9
14th Jul 2022, 9:46 AM
Jayakrishna 🇮🇳
+ 2
Thank you🙈 I completely forgot to print it, I thought it'd do that automatically
14th Jul 2022, 9:56 AM
Magadjiya
Magadjiya - avatar
+ 1
I've tried round(23.67) Expected output = 24 Gotten output = No output. I've tried setting it in a variable, x = 7.22818 round(x) Expected output= 7 Gotten output = No output. I've also tried round(12.2168, 2) Expected output = 12.22) Gotten output = No output.
14th Jul 2022, 9:50 AM
Magadjiya
Magadjiya - avatar