Discuss Scratch

TheAnomalousPseudo
Scratcher
1000+ posts

Even or Odd number sorter

scratch___user12345 wrote:

oops the image did not work
This is about the fourth time this topic has been necroposted.
CST1229
Scratcher
1000+ posts

Even or Odd number sorter

scratch___user12345 wrote:

file//media/fuse/drivefs-9c06423a8b863c8997cd065d6da1fd89/root/Screenshot%202021-04-28%2010.20.53%20AM.png
Please don't necropost.
You can't use file:// links for images since they're only on your computer, you can only use the whitelisted image hosts (cubeupload is recommended) and you didn't even put it inside an image tag.

Last edited by CST1229 (April 28, 2021 15:51:54)

snakeo666
Scratcher
13 posts

Even or Odd number sorter

when green flag clicked
if <((number) / (2)) = (round ((number) / (2)))> then
add (number) to [list even]


else
add (number) to [list odd]
end

Last edited by snakeo666 (Oct. 19, 2021 04:32:21)

vudeptrai090211
Scratcher
1000+ posts

Even or Odd number sorter

here's mine
when green flag clicked
set [number v] to [something]
if <((number) mod (2)) = [0]> then
say [It is an even number.]
else
say [It is an odd number.]
end

Last edited by vudeptrai090211 (Oct. 19, 2021 10:30:18)

joshhidalgo
Scratcher
1 post

Even or Odd number sorter

deck26 wrote:

FatCatOn1Mat wrote:

deck26 wrote:

RholanT3344 wrote:

when green flag clicked
set [odd v] to [1]
set [even v] to [2]
repeat ([half v] of (...)::operators)
add (even) to [even2 v]
change [even v] by (2)
end
repeat (...)
add (odd) to [odd2 v]
change [odd v] by (1)
end
Doesn't match the question which was about 10 random numbers - otherwise a good method to create odd and even lists.
Please don't necropost - you've just quoted an old post for no reason.
yes true please don't do that
LittleHeroFish
Scratcher
100+ posts

Even or Odd number sorter

umm, you can use this
if <((number) mod (0)) = [0]> then 
number is even
else
number is odd
end

Last edited by LittleHeroFish (Oct. 20, 2021 17:04:05)

vudeptrai090211
Scratcher
1000+ posts

Even or Odd number sorter

LittleHeroFish wrote:

umm, you can use this
if <((number) mod (0)) = [0]> then 
number is even
else
number is odd
end
number mod 2, not 0
LightningTPN
Scratcher
90 posts

Even or Odd number sorter

There is a simpler way to do this using the mod block.

(() mod ())

if <((random number) mod (2)) = [0]> then
add [random number] to [even v]
else
add [random number] to [odd v]
end

I think mod is the most forgotten block in Scratch.

Last edited by LightningTPN (Oct. 23, 2021 08:03:19)

sjfajjaj42
Scratcher
11 posts

Even or Odd number sorter

its very easy just do

if <((number) mod (2)) = [0]> then 
it's even!::motion
else
it's odd!::pen
end
sjfajjaj42
Scratcher
11 posts

Even or Odd number sorter

LittleHeroFish wrote:

umm, you can use this
if <((number) mod (0)) = [0]> then 
number is even
else
number is odd
end

umm you can't mod by 0 because moding is diving and taking the remainder, you cant divide by 0
EpicGhoul993
Scratcher
1000+ posts

Even or Odd number sorter

Jesus Christ. Please stop digging up this topic already.
cheddargirl
Scratch Team
1000+ posts

Even or Odd number sorter

EpicGhoul993 wrote:

Jesus Christ. Please stop digging up this topic already.
Yikes take it easy! Necroposting is allowed so long as the topic is relevant.
Xpert_Codes
Scratcher
2 posts

Even or Odd number sorter

when green flag clicked
if <(answer) = (answer)> then
set [number v] to ((answer) / (2))
if <not <[(answer)] contains [.]>> then
say [Even number] for (2) secs


else
say [Odd number]
end
end
EDGE_X
Scratcher
100+ posts

Even or Odd number sorter

Here I think this'll help:

(number)
(last number)
(even/odd)

when green flag clicked::control
set [number v] to (number::grey)
even or odd?
...

define even or odd?
set [last number v] to (length of (number))
if <<(letter (last number) of (number)) = [0]> or <<(letter (last number) of (number)) = [2]> or <<(letter (last number) of (number)) = [4]> or <<(letter (last number) of (number)) = [6]> or <<(letter (last number) of (number)) = [8]>>>>>> then::events
set [even/odd v] to [even]
...
else
set [even/odd v] to [odd]
...

Edit: Just saw a bunch of other posts on this topic and they say it's easy with the “( ) mod ( )” block

Last edited by EDGE_X (Oct. 23, 2021 15:27:37)

TheSmartGuy1234
Scratcher
1000+ posts

Even or Odd number sorter

Dtown10 wrote:

I am working on a project where scratch generates ten random numbers and puts them in a list. Whenever you press s the numbers are supposed to be sorted into 2 different lists even and odd. How do i sort the numbers.
this is what i have so far
https://scratch.mit.edu/projects/178918750/
<((number) mod (2)) = (0)>
will return true if even and false if odd
<((number) mod (2)) = (1)>
will return false if even and true if odd

edit: wow one block

Last edited by TheSmartGuy1234 (Oct. 24, 2021 20:47:26)

Nezon
Scratcher
1000+ posts

Even or Odd number sorter

cheddargirl wrote:

EpicGhoul993 wrote:

Jesus Christ. Please stop digging up this topic already.
Yikes take it easy! Necroposting is allowed so long as the topic is relevant.
But i don’t think this topic is. The OP is long gone and the topic already seems resolved.
Harakou
Scratcher
1000+ posts

Even or Odd number sorter

I think we've seen more or less the same ideal solution posted here multiple times, so let's call it resolved since this topic is from 2017. If anyone has additional questions, please ask in a new topic instead. Thanks.

(I agree with cheddargirl though, please take it easy! It's just a necropost. If you think something should be closed or removed, just report it.)

Last edited by Harakou (Oct. 24, 2021 22:00:13)

Powered by DjangoBB