What is mod short for in math?

Question

What is mod short for? Particularly when written X mod Y?

Answer

mod is short for modulo, a math function that means to get the remainder of division. It is represented with a % in python and written X % Y this can be read as X mod Y or X modulo Y.
It is used to get the remained from a division. For example:

15 % 4 = 3
>> 15 / 4 = 12 with remainder 3

For some further studying, see the Codecademy Python 3 modulo exercise.

I’m in the Lots of Math part of Python Functions. It’s the last screen before you complete the lesson.

It is asking me to “return the third number printed mod a.” What exactly is this asking me to do?

15 Likes

I had the same question. Mod is short for modulo, which is the % thing.

9 Likes

Mod means a lot for some of us, can be modules, modifications, moderations so fix this exercise asap because its confusing.

9 Likes

Finally, it should return the third number printed mod a, this is a poorly written step, whoever wrote this exercise, please, get down to our level, I know you are an expert, but this is the first time I learned about this word “mod” , this exercise is confusing! you can do a better job

4 Likes

Whilst the confusion is unfortunate, modular arithmetic is a mathematical system which existed long before the computer did.

The use of mod in this fashion is not confined solely to programming, nor to Codecademy’s material; it’s mathematics, so you’ll just have to get used to it I’m afraid. :slight_smile:

3 Likes

Terrible response from the Help Desk! Why make this more difficult by throwing in jargon that most don’t know. You could have easily left “mod” out and asked to return the remainder of ‘a’ and this thread wouldn’t exist!

1 Like

Programming is difficult, and learning by its very nature is going to involve a lot of things which are “unknown”. A good amount of your time, as a programmer, will likely be spent looking for information and learning about things you have either a) not seen before and/or b) don’t fully understand.

An example would be the use of mod in this context: you saw it, didn’t understand it, and went looking for more information to help you make sense of it before ending up here. This is a process with which you should become familiar. :slight_smile:

I can only presume, as I do not have access to the specific exercise (since I am neither a Pro member nor a Codecademy employee), that since this exercise deals specifically with the modulo operator that the specific statement of a mod b is intended to prompt the use of the % operator you have been learning about. It also introduces you to the notation. :slight_smile:

Otherwise, if the exercise simply asked for a remainder, you might derive some alternative mechanism for calculating it when a single operator is sufficient.

3 Likes

I agree with the prior response that this was a poorly written exercise. This is not the first time I’ve had trouble with the instructions.

1 Like

In any programming exercise, reading the instructions is crucial. It is clear enough to see what is coming in return for me.

def lots_of_math(a, b, c, d):
print(a + b)
print(c - d)
print((a + b) * (c - d))
return ((a + b) * (c - d)) % a

1 Like

Came here bc I was confused, and saw I wasn’t alone! I if there were a previous example explained with this verbiage, I would have known what to do.

Up until this point in the exercises % was always referred to as modulo so if they suddenly change how they refer to % it they should at the very least have an explanation in the hint if not in the actual instructions.