+ 1

7%(5//2) explain me this

28th Apr 2019, 8:36 AM
Edulla Basha
Edulla Basha - avatar
5 odpowiedzi
+ 9
Hey there 😃 7 % (5 // 2) takes the remainder of 7 divided by the floor of 5 // 2. 5 // 2 = 5 / 2 = 2.5 = floor 2.5 = 2 Then 7 % 2: 7 / 2 = 6 with a remainder of 1. This is because 2 can not go into 7, but it can go into 6. 7 - 6 = 1, where 1 is the remainder. 7 % 2 = 1 Hope it helps!
28th Apr 2019, 8:43 AM
Edwin Pratt
Edwin Pratt - avatar
+ 7
7℅(5//2) First we solve parenthesis so, 5//2=2 Now, 7%2=1 Answer is 👉 1
28th Apr 2019, 9:37 AM
Mohd Abdul Sameer
Mohd Abdul Sameer - avatar
+ 3
Avinash Avi // is integer division in python
28th Apr 2019, 10:15 AM
Anna
Anna - avatar
+ 2
[EDITED] IN TERMS OF C++ The code will return an error. Everything after this symbol // is ignored as a comment. So the code will try to calculate 7% (5 but can't calculate because a closing paranthesis is missing. The last paranthesis you have used will be considered as a comment and ignored.
28th Apr 2019, 9:05 AM
Avinash Avi
Avinash Avi - avatar
+ 2
Well, he didn't mentioned it so I explained it in terms of c++ concepts. Thank you for the clarification Anna.
28th Apr 2019, 11:09 AM
Avinash Avi
Avinash Avi - avatar