This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-08-17 15:32:26

ashfm
New Scratcher
Registered: 2011-08-17
Posts: 16

Using operators

New to scratch.

What is the simplest way to use operators (+, -, * and /) in Scratch? Do I have to use variables or could I simply use 9 + 1 and have Scratch give me the answer?

Cheers.

Offline

 

#2 2011-08-17 15:36:38

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Using operators

If you put in (9 + 1) the operator will give you 10.

Variables are mostly used for calculator projects like mine. (link to project)

Offline

 

#3 2011-08-17 16:07:10

ashfm
New Scratcher
Registered: 2011-08-17
Posts: 16

Re: Using operators

Thanks laptop97.

But I am new so how would I actually write this. Please give me an example.

Offline

 

#4 2011-08-17 16:11:57

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Using operators

ashfm wrote:

Thanks laptop97.

But I am new so how would I actually write this. Please give me an example.

Are you trying to create a calculator?

Offline

 

#5 2011-08-17 16:20:05

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Using operators

I think that by using operators you refer to simply having a script perform a mathematical calculation, and not necessarily making a project that acts as a calculator, right?

Scratch uses operator blocks that you give arguments, which then return your result. These (or any other "reporter" blocks) can be stacked inside of each other to make more complex expressions. The Scratch wiki has a more in-depth explanation on these and other blocks in the "operators" category here.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#6 2011-08-17 16:51:10

ashfm
New Scratcher
Registered: 2011-08-17
Posts: 16

Re: Using operators

Harakou wrote:

I think that by using operators you refer to simply having a script perform a mathematical calculation, and not necessarily making a project that acts as a calculator, right?

Scratch uses operator blocks that you give arguments, which then return your result. These (or any other "reporter" blocks) can be stacked inside of each other to make more complex expressions. The Scratch wiki has a more in-depth explanation on these and other blocks in the "operators" category

Thats right.

For example in Python we can can just write the code:

>>> print 5 + 3
8

And the answer 8 is given.

What is the simplest way of doing this in Scratch?

Thanks for your help.

Offline

 

#7 2011-08-17 16:53:04

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Using operators

ashfm wrote:

Harakou wrote:

I think that by using operators you refer to simply having a script perform a mathematical calculation, and not necessarily making a project that acts as a calculator, right?

Scratch uses operator blocks that you give arguments, which then return your result. These (or any other "reporter" blocks) can be stacked inside of each other to make more complex expressions. The Scratch wiki has a more in-depth explanation on these and other blocks in the "operators" category

Thats right.

For example in Python we can can just write the code:

>>> print 5 + 3
8

And the answer 8 is given.

What is the simplest way of doing this in Scratch?

Thanks for your help.

Does print mean to say it?

Offline

 

#8 2011-08-17 16:55:52

ashfm
New Scratcher
Registered: 2011-08-17
Posts: 16

Re: Using operators

laptop97 wrote:

ashfm wrote:

Harakou wrote:

I think that by using operators you refer to simply having a script perform a mathematical calculation, and not necessarily making a project that acts as a calculator, right?

Scratch uses operator blocks that you give arguments, which then return your result. These (or any other "reporter" blocks) can be stacked inside of each other to make more complex expressions. The Scratch wiki has a more in-depth explanation on these and other blocks in the "operators" category

Thats right.

For example in Python we can can just write the code:

>>> print 5 + 3
8

And the answer 8 is given.

What is the simplest way of doing this in Scratch?

Thanks for your help.

Does print mean to say it?

Yes it does - the answer is displayed on the screen.

Offline

 

#9 2011-08-17 16:58:24

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Using operators

Ok, then it would be

Say(X+Y) for (Z) secs

X, Y and Z are numbers you would put in

Offline

 

#10 2011-08-17 17:01:44

ashfm
New Scratcher
Registered: 2011-08-17
Posts: 16

Re: Using operators

laptop97 wrote:

Ok, then it would be

Say(X+Y) for (Z) secs

X, Y and Z are numbers you would put in

So I would have to use variables, right? Where X, Y and Z are variables.

I cannot just do a simple calculation like 3 + 3.

Offline

 

#11 2011-08-17 17:05:02

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Using operators

Download this

Offline

 

#12 2011-08-17 17:12:52

ashfm
New Scratcher
Registered: 2011-08-17
Posts: 16

Re: Using operators

laptop97 wrote:

Download this

Thats great. Thanks very much.

Offline

 

#13 2011-08-17 17:20:03

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: Using operators

ashfm wrote:

laptop97 wrote:

Download this

Thats great. Thanks very much.

Your welcome. If you have any more questions you can ask on the forums or see if you can find it in the Scratch Wiki

Offline

 

#14 2011-08-17 18:23:28

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Using operators

ashfm wrote:

Harakou wrote:

I think that by using operators you refer to simply having a script perform a mathematical calculation, and not necessarily making a project that acts as a calculator, right?

Scratch uses operator blocks that you give arguments, which then return your result. These (or any other "reporter" blocks) can be stacked inside of each other to make more complex expressions. The Scratch wiki has a more in-depth explanation on these and other blocks in the "operators" category

Thats right.

For example in Python we can can just write the code:

>>> print 5 + 3
8[/blocks]

And the answer 8 is given.

What is the simplest way of doing this in Scratch?

Thanks for your help.

I think laptop97 already cleared this up, but I'll answer just in case.

You don't necessarily have to use variables, but if you have two constants like that it would be a bit superfluous to do it that way. I'm sure that's just for an example though?

Regardless, I think this is what you're looking for:

http://i.imgur.com/Qoemx.gif


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#15 2011-08-17 21:06:57

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: Using operators

ashfm wrote:

laptop97 wrote:

Ok, then it would be

Say(X+Y) for (Z) secs

X, Y and Z are numbers you would put in

So I would have to use variables, right? Where X, Y and Z are variables.

I cannot just do a simple calculation like 3 + 3.

You can do this. Make 3 variables any thing you like (but be specific to avoid confusion) Set 1 variable to the amount of seconds you want. Set the other two for the two addends you want. Then put in a say block from Looks and put in an operators block (+) and put in the two addends (the two variables) in the plus block and put the variable for amount of seconds you want in the place where you can type in the amount of seconds you want. That should answer your problem.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#16 2011-08-18 00:03:23

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Using operators

But you can also add a variable and a number if you want.

Oh yeah, it's called constant. You can also add a variable and a constant if you want.

Last edited by kayybee (2011-08-18 00:04:40)

Offline

 

#17 2011-08-19 09:39:45

fuzzwuzz21
Scratcher
Registered: 2011-07-06
Posts: 15

Re: Using operators

those are used for calculators, so if you use  ((  <+>  ))    ((  <->  ))       ((  <*>  )) or     ((  </>  ))  something that has to do with the awnser happens so like if you use        <turn cw(  )degrees> [/blocks] so then if you put like   ((  <+>  ))     in there ill turn the awnser but you can also put things such as <mouse y> , <x position> , <size> and stuff in the ()s


SOPA and PIPA are dead. Next victim: ACTA.
united we stand, divided we fall. WE are the internet.                                  Spread the word.

Offline

 

Board footer