Discuss Scratch

Louisz27
Scratcher
29 posts

Mod block

What does the
(() mod (0))
do? I've seen it used numerous times, but I have no idea how it works.

Thanks!

Victory is but a prelude to the next battle.
deck26
Scratcher
1000+ posts

Mod block

a mod b is essentially the remainder after dividing a by b. So for whole numbers a mod 2 is 0 if a is even and 1 if a is odd.
Louisz27
Scratcher
29 posts

Mod block

deck26 wrote:

a mod b is essentially the remainder after dividing a by b. So for whole numbers a mod 2 is 0 if a is even and 1 if a is odd.
Okay. Thanks so much!

Victory is but a prelude to the next battle.
Homeless_Mario68
Scratcher
89 posts

Mod block

you can also think of ()mod() as kind of like a clock

((0) mod (12)) // 0
((1) mod (12)) // 1
((2) mod (12)) // 2
((3) mod (12)) // 3
((4) mod (12)) // 4
((5) mod (12)) // 5
((6) mod (12)) // 6
((7) mod (12)) // 7
((8) mod (12)) // 8
((9) mod (12)) // 9
((10) mod (12)) // 10
((11) mod (12)) // 11
once the first number goes past the second number it wraps back around

((12) mod (12)) // 0
((13) mod (12)) // 1
((14) mod (12)) // 2
((15) mod (12)) // 3
((16) mod (12)) // 4
((17) mod (12)) // 5
((18) mod (12)) // 6
((19) mod (12)) // 7
((20) mod (12)) // 8
((21) mod (12)) // 9
((22) mod (12)) // 10
((23) mod (12)) // 11

Currently making a real video game using pygame, so I probably wont release too many projects on scratch for a while

here is what I consider to be my best project, it is similar to paper minecraft in a way: https://scratch.mit.edu/projects/868963082/
Louisz27
Scratcher
29 posts

Mod block

Homeless_Mario68 wrote:

you can also think of ()mod() as kind of like a clock

((0) mod (12)) // 0
((1) mod (12)) // 1
((2) mod (12)) // 2
((3) mod (12)) // 3
((4) mod (12)) // 4
((5) mod (12)) // 5
((6) mod (12)) // 6
((7) mod (12)) // 7
((8) mod (12)) // 8
((9) mod (12)) // 9
((10) mod (12)) // 10
((11) mod (12)) // 11
once the first number goes past the second number it wraps back around

((12) mod (12)) // 0
((13) mod (12)) // 1
((14) mod (12)) // 2
((15) mod (12)) // 3
((16) mod (12)) // 4
((17) mod (12)) // 5
((18) mod (12)) // 6
((19) mod (12)) // 7
((20) mod (12)) // 8
((21) mod (12)) // 9
((22) mod (12)) // 10
((23) mod (12)) // 11
Cool! Thank you so much.

Victory is but a prelude to the next battle.

Powered by DjangoBB