- 1
About a back slash caliculation
(5//1.5) what will be the output and how
4 Answers
+ 2
Okay, actually they are double forward slashes. So the output of(5//1.5) is going to be 3.0.
Why?
This is my method:
Change 1.5 to 15 to make it easy for you.
Then ask yourself how many times will 5 multiply 15. It's three times,right?
Because it included a float which is 1.5 in this case, your answer must be in a float. So you just add a .0 to the 3 to get 3.0 as your answer.
+ 2
282 / 5,000
Resultados de traducciĆ³n
import math
print((5/1.5))#3.3333333333333335
print((5//1.5))#3.0
print(float(math.floor((5/1.5))))#3.0
print((5//2))#2
print(math.floor((5/2)))#2
it is the same as doing a floor which returns the integer without decimals obviously if you divide for a float you will get a float
+ 1
That is my easy method. My method is to get rid of the decimal first to prevent confusion then I introduce the decimal after I get my answer. And it works.
0
What ever value it is we need to remove float and calculate the value right?