+ 5
I dont understand what is the % and //
My discord account is Misa#8103
23 Réponses
+ 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.}
+ 5
Dev Shivnandan Mishra
Exactly
+ 3
Uhm but im bad at math, can u sa clearly and gimme some examples?
+ 3
Ohh i got this
+ 3
% - gives reminder of the devision.
// - tell how many times a number goes to a specific number.
+ 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
+ 2
Ohh ok
+ 2
print(10//3)=3
print(10/3)=3.333333........:
print(10%3)=1
+ 2
The sudden discord account though, lol
+ 1
// is comment in C or C++ Or Java...
But,
// is an operator in python that gives quotient...
+ 1
What's the difference in
While and if statement??😞
+ 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.
+ 1
Eg: 5%2 =1(which is the remainder)
But 5//2 = 2(because 2 goes into 5 two times)
+ 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.
+ 1
When you are diving numbers
%, // - allow you to find reminder & quotient respectively
//
+ 1
And /* if you want to comment multiple lines (perhaps paragraph) and you close like this at end of paragraph*/
0
// is comment
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 .
0
// use for comment
% use for percantag
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