# 2.4 Scr0140: arithmetic operators  (Page 5/7)

 Page 5 / 7

## Constructing the script

That seems straightforward enough. However, the process of constructing that script contains some new material, so I will walk you through the process.

Image 3 shows the state of the development process immediately after the blocks for the variables named Sum and Diff have been dragged from the Variables panel to the center panel and connected to the block that reads when button clicked .

## Not exactly what we want to happen

In Image 3 , as it stands now, the variables named Sum and Diff will be set to a value of zero when the user clicks the button. That isn'twhat we want, so we have some more programming to do.

The desired behavior is for the value of the variable named Sum to be set to the sum of the variables named LeftOperand and RightOperand when the user clicks the button. Similarly, we want the value of thevariable named Diff to be set to the difference between those two variables.

## The Operators panel

The left panel in Image 3 shows the blocks that are exposed when the green button labeled Operators is clicked.

Eleven of those blocks are of the correct shape to fit into the white boxes in the two bottom orange blocks inthe center panel. This means that we could drag any one of those eleven blocks and drop them into those white boxes.

## Four arithmetic operators

The top four green blocks in the left panel of Image 3 are particularly interesting. They contain the following arithmetic symbols as part of their labels:

• +
• -
• *
• /

These are the symbols that are commonly used for addition, subtraction, multiplication, and division in computer programming. The top two matchwhat you are accustomed to seeing on your hand calculator, but the bottom two probably don't match.

## Use an asterisk for multiplication

Most programming languages use the * character instead of the X character for multiplication in order to keep the multiplication operator frombeing confused with the letter that uses the X symbol.

## Use a forward slash for division

Insofar as division is concerned, most computer keyboards don't have a symbol that matches the symbol commonly used for division on hand calculators, so the /character is used instead.

## More blocks of the correct shape

Before leaving the discussion of the left panel in Image 3 , I will explain the behavior of four additional blocks that are of the correct shape forbeing dropped into the white boxes in the variable blocks in the center panel. (The remaining blocks beyond those four deal with strings, which I will ignore for now.)

## Random numbers

The block labeled pick random 1 to 10 lets you enter other values in place of 1 and 10. Then this block will deliver a random number withinthat range when it is called upon to do so. Random numbers are often used in game programs to simulate the throwing of dice or the spinning of a wheel offortune.

## The modulus

The block labeled mod will produce the modulus of two values when called upon to do so. The modulus of two numbers is the remainder thatresults from dividing one number by another number. You may remember the remainder from when you learned to do long division in elementary school butbefore you learned about decimals.

#### Questions & Answers

Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
Sanket Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

### Read also:

#### Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Teaching beginners to code. OpenStax CNX. May 27, 2013 Download for free at http://cnx.org/content/col11498/1.20
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?

 By Danielrosenberger By By Eric Crawford By Mistry Bhavesh By By Anindyo Mukhopadhyay