Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
+ 12

Why is the answer of 7% (5//2)= 1?

4th Jan 2017, 3:23 PM
Kitty Babes
18 Réponses
+ 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!
4th Jan 2017, 10:11 PM
Tristan McCullen
+ 10
Maybe she found it in a quiz?
4th Jan 2017, 3:55 PM
Valen.H. ~
+ 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)
4th Jan 2017, 3:29 PM
Yanothai Chaitawat
+ 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
4th Jan 2017, 6:28 PM
stephen haokip
+ 1
Good question. @kitty Babes will you post it as a quiz?
4th Jan 2017, 3:34 PM
ifl
+ 1
She found and just ask us?for what?
4th Jan 2017, 3:57 PM
Yanothai Chaitawat
+ 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
4th Jan 2017, 4:03 PM
Leonida17st
+ 1
Derp! I forget this is a phyton question not c# question
4th Jan 2017, 4:21 PM
Yanothai Chaitawat
+ 1
Note that 5//2 is 2 but -5//2 is -3
5th Jan 2017, 11:02 AM
ifl
+ 1
KFC forover
5th Jan 2017, 6:40 PM
negro_KFC
0
In python // is not for comment, and can be used instead for this 'floor' div operator.
4th Jan 2017, 4:15 PM
ifl
0
5//2 means how many 2 divides 5 discarding decimal
5th Jan 2017, 10:17 AM
Dhulipala Srikanth
0
5//2=2 7%2=2*4+1 if you consider division algorithm 1 is the remainder since% in programming refers to remanider
5th Jan 2017, 11:08 AM
Dhulipala Srikanth
0
Follow PEMDAS and you are done
5th Jan 2017, 7:13 PM
Harsh Shah
0
operations in parentheses precedes all others, so the equation changes to 7%2 and thus the answer is 1
7th Jan 2017, 12:48 PM
Tarun Kumar Singh
0
// is give quotient so 5//2 = 2. % this is used for find remainder. 7 % 2 = 1 gives remainder 1
17th Jan 2017, 2:22 AM
Mayur Chaudhari
0
according to bodmas bracket is solved first . quotient of 7/2 is 2. so 7%2 is 1.
29th Jan 2017, 12:54 PM
Vinayak Gupta
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
4th Feb 2017, 12:00 PM
Shivam Bhatt
Aujourd'hui en vedette
Help!