Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
Ah, so you mean which to calculate first? % is ranked like division or multiplication. If you have several of these in a row, they'll be evaluated from left to right. Whenever you need to figure out the order of operations in Python, this is your go-to source: https://docs.python.org/3/reference/expressions.html Scroll down to 'operator precedence', there you'll find it all. Watch out: Starting from slowest. 😉
2nd Nov 2019, 11:51 AM
HonFu
HonFu - avatar
+ 5
You may have to modify the acronym to "Please Excuse My Dear Mad Aunty Sally," with the Mad being added to represent modulo.
3rd Nov 2019, 4:57 AM
Sonic
Sonic - avatar
3rd Nov 2019, 5:42 AM
Sonic
Sonic - avatar
+ 2
Whenever you need to know if something is cleanly divisible. if n%2==0: print('even') Or when you want to know what remains after you divided. cookies_left = cookies%number_of_persons % is a partner of //. Let's say you have 29 cookies and want to share them among 3 people, but you can't break any cookie. per_person = 29 // 3 Everybody gets 9 cookies. How many cookies will be left over? cookies left = 29 % 3 2 cookies.
2nd Nov 2019, 11:17 AM
HonFu
HonFu - avatar
+ 1
Solve the bracket first then multiply the result with A, then take % and subtract 9 from the final result.
2nd Nov 2019, 12:23 PM
Avinesh
Avinesh - avatar