< Language Tutorials

This is an example project for the Ruby language, which generates numbers from 4 to 301 in increments of 3 until X equals 100 minus Y.

x = rand(1..100)
y = rand(1..100)
until x == (100-y)
 print (x*3+1)
 puts "\n"
 x = rand(1..100)
 y = rand(1..100)
 sleep 1
end

In Scratch, this code is shown as:

when gf clicked
set [x v] to (pick random (1) to (100))
set [y v] to (pick random (1) to (100))
repeat until <(x) = ((100) - (y))>
add (((x) * (3)) + (1)) to [print v] // The print command is not really implemented in Scratch, so there is a list instead. Also, "\n" has no meaning in Scratch.
set [x v] to (pick random (1) to (100))
set [y v] to (pick random (1) to (100))
wait (1) seconds
end
stop [this script v]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.