9 Respuestas
+ 2
Wizking754👻 this is usually working of each programming language, if you convert it to an integer in this way, the digits after decimal point will be cutted off:
number=5.7
print(int(number))
# >> 5
+ 11
Wizking754, Your statement is not correct:
print(round(3.14)) gives 3
print(round(3.77)) gives 4
May be you should share your code that creates your result here. Thanks!
+ 5
It doesn't. The round() function returns a floating point number that is a rounded version of the specified number, with the specified number of decimals.
Maybe you mean int(). That is casting, not rounding. Use round(f) if you want the nearest integer to f
+ 1
Wizking754👻 use round() for rounding, not int(). Read my answer again
+ 1
Wizking754👻 You are casting to Integer equalent.
This is Rounding :
number=5.7
print(round(number))
0
Proof?
0
Benjamin Jürgens probably didnt fully explain myself well. Below is my question
https://code.sololearn.com/c3t2A7rHzMo9/?ref=app
0
Benjamin Jürgens rather than getting 6 it still results to 5. Hope my question is understood Lothar Jayakrishna🇮🇳
https://code.sololearn.com/c3t2A7rHzMo9/?ref=app