How do we round off values in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do we round off values in python?

?

26th Oct 2020, 8:32 AM
coder_20
9 Answers
+ 4
https://code.sololearn.com/ceA3u1zBKs3b/?ref=app value = 3.141592 print(round(value, 4)) result == > 3.1416
26th Oct 2020, 9:09 AM
Gabriele Gatti
Gabriele Gatti - avatar
+ 3
Try using round() function Learn more about it here👇 https://www.geeksforgeeks.org/round-function-JUMP_LINK__&&__python__&&__JUMP_LINK/
26th Oct 2020, 8:41 AM
Arsenic
Arsenic - avatar
+ 2
5//3 = 1
26th Oct 2020, 8:34 AM
Oma Falk
Oma Falk - avatar
+ 2
Thanks🙏
26th Oct 2020, 8:44 AM
coder_20
+ 1
from math import ceil rounded_value = ceil(value)
26th Oct 2020, 8:47 AM
Louis AMOUDRUZ
Louis AMOUDRUZ - avatar
+ 1
coder_20 You can make or convert that number in integer by using int() so it will automatically converted in round off
28th Oct 2020, 5:03 AM
VIGNESH MARADIYA
VIGNESH MARADIYA - avatar
+ 1
coder_20 Use round(value to be round off, up to how many decimal place) Example: volume=1289.4893 round(volume , 2) Output: 1289.49
30th Oct 2020, 7:40 AM
VIGNESH MARADIYA
VIGNESH MARADIYA - avatar
0
Suppose we get 1.9, it will return 1only won't it?
26th Oct 2020, 8:35 AM
coder_20
0
Thanks😊
26th Oct 2020, 8:56 AM
coder_20