But what does the percent sign mean as well as the // How does it work? I do not understand? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

But what does the percent sign mean as well as the // How does it work? I do not understand?

Before I edit this, I thought it linked the module, it did not, so that’s why my questions was blank

23rd Jul 2019, 12:44 AM
Wahaj Akhtar
Wahaj Akhtar - avatar
6 Answers
+ 6
In javascript this works like this👇I don't know whether it's works same in Python tho🤔 some people say javascript and python are related 🤷 // is single line comment Whatever you write inside that, those codes will be ignored (right side) % is use for leftover number For example: If you write var x= 365; var y= 27; Document.write( x % y); The output will be 14 here is math: --> 365/27 = 13.51851... (take the number before the ".") -->13*27 = 351 (take this answer) -->365-351 = 14 In other way... (x - leftover = answer) 365 - 14 = 351 (take the answer to divide) (previous answer / y = answer) 351 / 27 = 13 ( take the answer to subtract) (y - answer = output) 27 - 13 = 14
23rd Jul 2019, 2:48 AM
KingDaniel2004
KingDaniel2004 - avatar
+ 2
The % is a modulo operator. It returns the remainder after division. Example is 4 % 3 = 1 or 7 % 5 = 2, it gets tricky with negative numbers and changes from language to language. The // is an integer division operator. It will never give you a float answer. Example is 7 // 3 = 2 or 5 // 4 = 1.
23rd Jul 2019, 2:45 AM
Pete Cowling
Pete Cowling - avatar
+ 2
the floor division(//) sign is used to determine the quotient of a division while a modulo sign(%) is used to determine the remainder of a division e.g 4//2=2, while 4%2=0
23rd Jul 2019, 9:08 AM
austin nyoike
0
What? Please give us as community and me more information
23rd Jul 2019, 1:00 AM
Nico Ruder
Nico Ruder - avatar
0
What? Please give us as community and me more information
23rd Jul 2019, 1:00 AM
Nico Ruder
Nico Ruder - avatar
0
otherwise i cant help you
23rd Jul 2019, 1:01 AM
Nico Ruder
Nico Ruder - avatar