7%(5//2) =1. please explain. I don't understand how they get 1? | Sololearn: Learn to code for FREE!

+27

7%(5//2) =1. please explain. I don't understand how they get 1?

12/7/2015 6:28:00 AM

Sean

46 Answers

New Answer

+75

Floor division: How many 2s fits inside 5 ? = 2 Modulus/Remainder: How much space wasn't used when fitting the 2 inside 5 ? 1 space

+63

how many times can 2 fit into 5(5//2)the answer is 2 times. so the equation is 7% (2), 2 fits into 7 three times with a remainder of 1. so the answer is 7% (5//2)=1

+54

when 5is divided by 2 the quotient is 2 and when 7 is divided by quotient 2 remainder is 1 (//represent quotient and % represent remainder)

+44

Step 1: Solve the parentheses (5//2) It will output 2, because we are doing floor division. Our output will be in Integer. By simple division (5/2), it will output 2.5, because it prints the value in float. So 5//2 = 2 Now we have 7%(2) Step 2: %(modulus) sign is used for remainder. when we divide 7 by 2, we have remainder 1. 7%2 = 1 So, It will print 1. Hence our answer will be 1.

+19

5//2=4/2=2; then 7%2=7-2*3=1

+10

it's actually asking what is left after fitting the 2 (from 5//2) inside 7, witch is always 1 with any odd number

+10

In python3 // means result is integer. so 5//2 reault is 2. and then 7%2 means you want a remainder of 7/2. So finally get 1

+8

[img]http://i.imgur.com/kPcQsWb.png[/img] 7%(5//2)=1 Step 1: (5//2) = 2 (floored quotient) Step 2: 7%2 = 1 (remainder) Hence: 7%(5//2) = 1

+7

first 5//2 means 5 how many 2 then 7%2 mean divide 7 until there is no 2 7/2=5/2=3/2=1

+7

I think I understand. so: 7%(5//2) -> 7%(2) -> we discard the remainder (.5) -> so: 7%2 = 3.5 -> we discard the remainder (.5) again. So: 3/2=1.5 -> discard remainder (.5) =1 Couldn't we also just multiply the remainder by 2 or would that not work uniformly?

+4

(5//2) = the answer is 2. Then 7 % 2, for this you need to find the remainder to get the 7. 7 = ... * 2 + remainder. 7 = 3 * 2 + remainder 7 = 6 + remainder, so 7 = 6 + 1 7= 7 You need make it to the closest number for the multiplication. . If u got 7= 1*2 + 5 this are wrong. Then if u do this: 7 = 4*2+? You cant get the 7.. So try the closest multiplication till you cant get the 7(number that you want to search the remainder) sorry for bad English. Hope this help you..

+4

// mean u will get quotient % mean u will get remainder

+4

5//2 = 2 7/2 = 6 r1 (We use the remainder)

+3

In Python by default take float data type So any division calculations it will give us floating value Suppose that 24/12 = 2.0 not 2 But 24 // 12 = 2 not 2.0 Try to understand difference / - is division it will give floating value // - is floor division it will give integer value

+2

Since 5//2 = 2 why 2 ? because we have to check how many times does 2 exactly makes 5 but we can't figure out so we take nearest that is 4 so 4 is two times 2 hence 5//2= 2 now 7%(5//2) = 7%2 = remainder when 7 gets divided by 2 so 7%2 =1

+2

firstly it gives floor value 2 then 7 modules 2 gives remainder which is 1

+2

% operator means remeinder .. whereby 5÷2 =2 7%2 that is 7÷2=3 remeinder 1.. 😊

+2

You know it's a good thread when people are still trying to answer this question more than 3 years later.

+1

this is actually modular division which means that if u divide 7 by 5/2 the remainder is 1

+1

its very simple here 5//2 will return an integer because 5/2 returns a float result, but 5//2 will return a int result which is 2 , and hence 2%7 gives modulous as 1