+ 5

Phyton challenge

What is the output of this code? a = abs(-87) a=(a+3)%8; print(a) Can anyone explain about this?

14th Mar 2021, 11:03 AM
Meehzam
Meehzam - avatar
45 Answers
+ 24
Meehzam I'm sure you already know this, but Python is a snake and the name of a programming language. Phyton is of course the Suel god of Nature, Beauty, and Farming, whose symbol is a scimitar in front of an oak tree. 🤣
14th Mar 2021, 12:04 PM
David Ashton
David Ashton - avatar
+ 11
Abs of -87 is 87 a=87 a+3= 90 90%8 = 2
14th Mar 2021, 11:13 AM
Sâgærāvürï
Sâgærāvürï - avatar
+ 11
Now this is really starting to drive me crazy 😜 Why are so many people (not to mention any names Jasurbek Abdijalilov Sobirjon o'g'li [user id="19938623"]Alexander Genereaux[/user] [user id="21318449"]Techno[/user] [user id="21118391"]Reda[/user] ) posting the same answer hours and hours and hours after someone else already posted it? 🤔 Don't get me wrong - it's great that you are participating and helping! Just strange that you didn't see the other posts.... Did you think the request for help was a coding challenge? P.S. if you really want to help, rather than just posting the output of the code, also give an explanation, which was asked for 🙂
15th Mar 2021, 11:18 PM
David Ashton
David Ashton - avatar
+ 10
David Ashton The sad truth: For some, it is more important to show that they know the answer than to help the questioner. Sometimes we should hold back our own ego a little.
15th Mar 2021, 7:41 PM
Crash Metal
Crash Metal - avatar
+ 9
Why are so many people (not to mention any names Reda [user id="15783731"]Pankaj Kumar Ray[/user] [user id="12524637"]saimanasa bandaru[/user] [user id="21165204"]Rohith Jakkani[/user] ) posting the same answer hours and hours after someone else already posted it? 🤔 Don't get me wrong - it's great that you are participating and helping! Just strange that you didn't see the other posts.... P.S. if you really want to help, rather than just posting the output of the code, also give an explanation, which was asked for 🙂
15th Mar 2021, 7:14 PM
David Ashton
David Ashton - avatar
+ 6
Giovanni Reale you, too, get 10/10 for good intentions but 2/10 for powers of observation since the answer 2 was posted 12 hours before you did 🤣
15th Mar 2021, 1:45 AM
David Ashton
David Ashton - avatar
+ 6
Inglés: Absolute of -87 is 87. So a=87 a=(87+3)%8 a= 90%8 8*11=88. 90-88=2=a a=2 Español: Valor absoluto de -87 es 87. Entonces a=87 a=(87+3)%8 a= 90%8 8*11=88. 90-88=2=a a=2
15th Mar 2021, 4:19 PM
Emerson Rueda
Emerson Rueda - avatar
+ 5
14th Mar 2021, 11:09 AM
Sâgærāvürï
Sâgærāvürï - avatar
+ 4
Can you explain it with the simple and understandable way? 🙂
14th Mar 2021, 11:11 AM
Meehzam
Meehzam - avatar
+ 4
Oh I think I get it, what is the meaning of this abs?
14th Mar 2021, 11:16 AM
Meehzam
Meehzam - avatar
+ 4
Absolute value
14th Mar 2021, 11:17 AM
Sâgærāvürï
Sâgærāvürï - avatar
+ 4
a = abs(-87) => 87 a=(a+3)%8; => 87+3 =90 print(a) => 90%8 = 2 ---------------------
15th Mar 2021, 5:57 PM
‎Emad Esmail ‎
‎Emad Esmail ‎ - avatar
+ 3
2
14th Mar 2021, 11:12 PM
Giovanni Reale
Giovanni Reale - avatar
+ 3
Abs means that you negative number will turns positive. Then add the a value with 3. Then computer will find the a value remainder
15th Mar 2021, 4:05 AM
Dan
Dan - avatar
+ 3
a = abs(-87) #a=87 a=(a+3)%8; #a=(87+3)%8=90%8=2 print(a) # the printed value is 2
15th Mar 2021, 10:59 AM
Riahi Firas
Riahi Firas - avatar
+ 3
Btw thanks all for the information you gave 😊
16th Mar 2021, 8:28 AM
Meehzam
Meehzam - avatar
+ 2
Ohh okayy thanks for the information 😊
14th Mar 2021, 11:18 AM
Meehzam
Meehzam - avatar
+ 2
8 * 11 is 88 with a remainder of 2 for 90 % 8 = 2 .... u get it 8 goes into 90 , 11 times... , with a remainder of 2... the abs in -87 just turns it into 87
15th Mar 2021, 7:28 PM
Roodstillwell Fenelon
Roodstillwell Fenelon - avatar
+ 2
Meehzam abs means reverse -87 to +87 a is now +87 + 3 % is modulus, this division only returning a reminder. And your output is 2 instead of 11.2. Easiest explanation.
15th Mar 2021, 9:13 PM
Steve Nova
Steve Nova - avatar
+ 2
I don't know why my question is so hot today 😂
16th Mar 2021, 8:13 AM
Meehzam
Meehzam - avatar