I dont understand what is the % and // | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

I dont understand what is the % and //

My discord account is Misa#8103

15th Nov 2021, 3:16 AM
Yamada Misaki
Yamada Misaki - avatar
23 Answers
+ 11
❖ Modulos : / (it shows remainders) ex: (5 % 2) = 1 {In short do simple division until you get number which can not be divide further, that last non dividable number is modulos} ❖ Floor Division : // (same as simple division but remember few points given below) # if numbers are positive (results without float) ex : Simple division» (5/2) = 2.5 Floor division» (5 // 2) = 2 {If simple division gives values like 1.6, 5.9, 3.4 then it will become 1, 5, 3 respectively in floor division, in short remove all numbers after decimal point} # if one number is negative ex : Simple division» (-5/2) = -2.5 Floor division» (-5 // 2) = -3 {when number is negative floor division round up -2.5 to -3, in short if answer is negative and numbers after point is > 0, then add (-1) to get value floor division.}
16th Nov 2021, 8:28 AM
Sujal
Sujal - avatar
15th Nov 2021, 1:12 PM
CGO!
CGO! - avatar
+ 3
Uhm but im bad at math, can u sa clearly and gimme some examples?
15th Nov 2021, 3:30 AM
Yamada Misaki
Yamada Misaki - avatar
+ 3
Ohh i got this
15th Nov 2021, 3:37 AM
Yamada Misaki
Yamada Misaki - avatar
+ 3
% - gives reminder of the devision. // - tell how many times a number goes to a specific number.
15th Nov 2021, 11:06 PM
Monika Kujawa
+ 3
% -modulo operator- use this to get REMAINDER from calculation of two numbers eg 10%3=1 because 3 goes into 10 three times and remainder is 1. // -floor division- use this to floor a division of two numbers eg 10//3 = 3. To floor means to have result that is an integer like 3 not a float like 3.333. if you use 10/3 =3.333
16th Nov 2021, 7:02 AM
david chongo
david chongo - avatar
+ 2
Ohh ok
15th Nov 2021, 11:34 PM
Yamada Misaki
Yamada Misaki - avatar
+ 2
print(10//3)=3 print(10/3)=3.333333........: print(10%3)=1
16th Nov 2021, 5:02 AM
Bharathi R
Bharathi R - avatar
+ 2
The sudden discord account though, lol
16th Nov 2021, 11:20 AM
Vachila64☕
Vachila64☕ - avatar
+ 1
// is comment in C or C++ Or Java... But, // is an operator in python that gives quotient...
16th Nov 2021, 6:39 AM
ISHIKA SHARMA
ISHIKA SHARMA - avatar
+ 1
What's the difference in While and if statement??😞
16th Nov 2021, 11:07 AM
Hallucinatory
Hallucinatory - avatar
+ 1
Thanks Bro I have been trubeling to understand about Modulos and floor division but now I actually know how it work and how to use it.
16th Nov 2021, 12:22 PM
Saffiafiz Kabba
Saffiafiz Kabba - avatar
+ 1
Eg: 5%2 =1(which is the remainder) But 5//2 = 2(because 2 goes into 5 two times)
16th Nov 2021, 4:01 PM
Elizabeth Amihere
Elizabeth Amihere - avatar
+ 1
% is known as modulos and it gives the remainder of the division. // is known as floor division and it gives us how many times a number goes to a specific number. Edit for example: In floor division: 20//6 The answer is 3 because 6 goes to 20 three times. And in modulos: 19%6 The answer is 1 because 6 can be divided by 18 but 19 is one number greater.
16th Nov 2021, 4:37 PM
Mumtaz Ali
Mumtaz Ali - avatar
+ 1
When you are diving numbers %, // - allow you to find reminder & quotient respectively //
16th Nov 2021, 7:49 PM
Chere Lemma
+ 1
And /* if you want to comment multiple lines (perhaps paragraph) and you close like this at end of paragraph*/
27th Jan 2022, 9:31 AM
Kevin Merric
Kevin Merric - avatar
0
// is comment
16th Nov 2021, 6:32 AM
Thinley Namgay
Thinley Namgay - avatar
0
Modulos is about how many times a number can goes into another number and the reminder is what we consider as the answer is what Modulos is about .
13th Jan 2022, 11:09 AM
Saffiafiz Kabba
Saffiafiz Kabba - avatar
0
// use for comment % use for percantag
14th Jan 2022, 7:36 AM
Mumtaz Ali
Mumtaz Ali - avatar
0
// is talking about how many times a number can be divided with out a reminder 🎗️ While % passentage or modulus is talking about the reminder of any divided figure. Direct me if am on the wrong Parth
17th Jan 2022, 8:01 PM
Saffiafiz Kabba
Saffiafiz Kabba - avatar