Discuss Scratch

andyman11
Scratcher
100+ posts

What Does the mod block do

Most pepole Know Every block but the mod block
Uniquename1
Scratcher
100+ posts

What Does the mod block do

Right click on it and select help. Says it gives the remainder of the division of 2 numbers… what good is that we might say? Most useful is to see if the mod is zero (i think) because that way i think it means they go into each other evenly. So for regularly recurring intervals like every time score goes up by 1000 change next level you can use that but I'm not 100% sure how'd you'd write it but you'd use it somehow. Surely other uses for it too. If 1000 mod score where score is the variable equals 0 would mean 1000 goes into the score evenly or something like that then it waits until the next time 1000 mod score equals 0. But again i'm not sure on the order or specifics and may give you a problem if you don't always land exactly on the target score/ interval.
andyman11
Scratcher
100+ posts

What Does the mod block do

That Is very Complex for me
TheLogFather
Scratcher
1000+ posts

What Does the mod block do

The simplest way to think of “mod” is that is gives the *remainder* when dividing by something.

So, for example:
30mod7 gives two, since 30 divided by 7 gives 4 remainder 2

More generally, the operation (M mod N) will give (in Scratch) a value ranging from zero to N-1 (that's assuming M and N are both whole numbers – I won't go into the case of M and/or N not being whole numbers here, where the highest value (M mod N) can return is then just under N).

In mathematics this corresponds to something called "modular arithmetic". This is like doing arithmetic on the face of a clock, where the numbers ‘wrap around’ once they reach a certain value – but in mathematics it starts at zero and would wrap around back to zero at the point where it would normaly reach twelve.

It's a *very* important and useful branch of mathematics – indeed, much of modern encryption methods make use of it (to secure data being sent across the internet, such as bank/card details when buying things online, for example…)

Last edited by TheLogFather (July 18, 2017 15:20:58)

FancyFoxy
Scratcher
500+ posts

What Does the mod block do

Here's one thing I used this block for:
...mod2=0 even...mod2=1 odd
yella01
Scratcher
2 posts

What Does the mod block do

i want to ask how to make game which has computer mode also and if we press it computer fights with us and if we jump on him he loses 1 live and if he touches us we lose 1 live?
DrGaming_92Games
Scratcher
100+ posts

What Does the mod block do

yella01 wrote:

i want to ask how to make game which has computer mode also and if we press it computer fights with us and if we jump on him he loses 1 live and if he touches us we lose 1 live?

Please make your own topic rather than posting on old topics (aka necroposting). You can find the new topic button at the top right of the forum page.
yella01
Scratcher
2 posts

What Does the mod block do

DrGaming_92Games wrote:

yella01 wrote:

i want to ask how to make game which has computer mode also and if we press it computer fights with us and if we jump on him he loses 1 live and if he touches us we lose 1 live?

Please make your own topic rather than posting on old topics (aka necroposting). You can find the new topic button at the top right of the forum page.
ok.
Blazing_Codes
Scratcher
37 posts

What Does the mod block do

andyman11 wrote:

Most pepole Know Every block but the mod block
The Mod block, which is in the operator catergory, represents the remainder of the two slots you put numbers in
For instance:
10mod3The program will report back as a value of 1 because 10÷3=3 (remainder 1)
Lets try another one:
72mod2This represent the value of 0 because 72÷2=36 (remainder 0)
I hope this helps!

Last edited by Blazing_Codes (May 25, 2024 04:21:16)

Powered by DjangoBB