+ 12
Why is the answer of 7% (5//2)= 1?
18 Respostas
+ 31
Welcome to the Sololearn community and congrats on deciding to be a programmer! :)
Let's dive in, shall we?
Your puzzle is 7 % (5 // 2) = 1 and this is how it gets calculated:
#Parentheses first
##5//2 is "floor division" and asks how many times two can go in five, without caring for the remainder (=2 times).
### 7 % 2 is "modulus" and asks what is left as the remainder after floor division of 2 in 7 = 6. (=1 left).
Hope this helped you and don't hesitate to be curious and ask in the future.
Cheers!
+ 10
Maybe she found it in a quiz?
+ 6
1 : 7 % (5/2)
2 : 7 % (2)
3 : 1
It equal 1 becus 7%2 it's a leftover number from 7/2
Sorry for grammar
And dont forget that % in js c++ java phyton is modulus not percent :)
(Edit : I forget this is python question)
+ 2
simple.. here // means the quotient so the quotient when 2 divides 5 is 2.
lastly % means the remainder. so the remainder here when 2 divides 7 is 1.
hope this helps... thanks
+ 1
Good question. @kitty Babes will you post it as a quiz?
+ 1
She found and just ask us?for what?
+ 1
one more important thing 5/2 will produce 2.5 , but 5//2 will proudce 2 ..when you put two "/" operators it will just give main part of number and throw decimal
+ 1
Derp! I forget this is a phyton question not c# question
+ 1
Note that 5//2 is 2 but -5//2 is -3
+ 1
KFC forover
0
In python // is not for comment, and can be used instead for this 'floor' div operator.
0
5//2 means how many 2 divides 5 discarding decimal
0
5//2=2
7%2=2*4+1
if you consider division algorithm 1 is the remainder
since% in programming refers to remanider
0
Follow PEMDAS and you are done
0
operations in parentheses precedes all others, so the equation changes to 7%2 and thus the answer is 1
0
// is give quotient so 5//2 = 2. % this is used for find remainder. 7 % 2 = 1 gives remainder 1
0
according to bodmas bracket is solved first .
quotient of 7/2 is 2.
so 7%2 is 1.
0
as we can see for 5//2 both on left and right side there are integer thus it gives the quotient which is here 2 iā¢e integer ; while (7%2) since as usual both are integer gives the remainder in integer which is here 1 . Hope U Get it Now