Discuss Scratch
- clay231
-
Scratcher
5 posts
New Block: () Is Even/Odd?
if <(round ((n) / (2))) = ((n) / (2))> then
even
else
odd
end
that's exactly what i did
- ARandomNumberIs7482
-
Scratcher
1000+ posts
New Block: () Is Even/Odd?
that's what i did tooif <(round ((n) / (2))) = ((n) / (2))> then
even
else
odd
end
that's exactly what i did
- snowbank4
-
Scratcher
59 posts
New Block: () Is Even/Odd?
if < ((num) / (2)) contains [.(period) ] ?> then
set [even_or_odd v] to [odd]
else
set [even_or_odd v] to [even]
end
Last edited by snowbank4 (July 23, 2023 19:55:29)
- medians
-
Scratcher
1000+ posts
New Block: () Is Even/Odd?
By the way, the contains operators block didn't exist in Scratch 2.0, so you're going to have to color it with scratchblocks syntaxif < ((num) / (2)) contains [.(period) ] ?> then
set [even_or_odd v] to [odd]
else
set [even_or_odd v] to [even]
end
Also I'm thinking you could also extend it to decimals like this:
https://scratch.mit.edu/discuss/post/7302132/
I've also noticed that the note input (such as the one in the Music extension) turns red when the given number is invalid, and it tries to correct the value when you click away, but other inputs don't do thatOh my god I never knew this I thought they would have kept this ability in 3.0, and I had to test this.
TIL!
And I'm not sure if it's my extensions, but I can only see the correcting value thing.



