<< Chapter < Page Chapter >> Page >

Various numeric representations

The block labeled sqrt will deliver about a dozen different representations of numeric values, depending on what is selected from thepull-down list. This includes the square root, trigonometric functions, absolute value, etc.

Rounding a number

Finally, the block labeled round will round a decimal number to the nearest whole number.

Drag and drop the plus and minus operators

Image 4 shows the result of dragging the top two green blocks from the left panel and dropping them into the white boxes in the bottomtwo orange variable blocks in the center panel of Image 3 .

Image 4. result of dropping addition and subtraction operators into variable blocks.

Missing image.
Image 4. Result of dropping addition and subtraction operators into variable blocks.

A few more steps are required

If you compare Image 4 with Image 2 , you will see that Image 4 is close to what we need but we aren't quite there yet. In order to causethe bottom two blocks in the center panel in Image 4 to match the bottom two blocks in Image 2 , we need to do the following:

  • Click the orange Variables button in the upper left of Image 4 to expose the variables as shown in Image 1 .
  • Drag the blocks for the variables named LeftOperand and RightOperand from the left panel and drop them into the white boxes in the bottom two blocks in Image 4 to make them match the bottom two blocks in Image 2 .

That's the solution. The upper left portion of your Stage area should now look similar to Image 5 . Note however that you may need to use the mouse to arrange the four variables and the button to get your Stage arrangedlike Image 5 .

Image 5. stage area of the finished program.

Missing image.
Image 5. Stage area of the finished program.

Operation of the program

Once you reach this point, you can click the green flag to initialize all four variables to zero.

Then you can move the sliders back and forth to manually set the values for the variables named LeftOperand and RightOperand .

Then when you click the button at the bottom of Image 5 , the variable named Sum will display the sum of the values of the top two variables, and the variable named Diff will display the value of LeftOperand minus the value of RightOperand .

An online version of this program is available

A copy of this program has been posted online for your review (see Resources for the URL) . If you don't find the program using that URL, search the Scratch site for the usernamed dbal.

Run the program

I encourage you to use the information provided above to write this program. Experiment with the code, making changes, and observing the results of yourchanges. Make certain that you can explain why your changes behave as they do.

Just for fun, move the button a little to the right and cause it to say Ouch for about five seconds each time you click it as shown in Image 6 . Hint: See the purple button labeled Looks in Image 3 .

Image 6. making the button say ouch.

Missing image.
Image 6. Making the button say ouch.

I also encourage you to write the program described below.

Student programming project

Write a Scratch program named Arithmetic02 that produces the output shown in Image 7 when the user adjusts the sliders to the values shown and clicks the button. Make the word Ouch! appear and then go away after about five seconds.

Questions & Answers

what is demand
Joseph Reply
Demand simply refers to the amount of goods and services which the consumer is willing and able to purchase at each price
Owusu
what is mean by unitary elastic demand
Bangniyel Reply
demand is said to be unitary elastic when the percentage change in the demand is equal to the percentage change in the price
George
what is the principle of equi-marginal utility
Reliance Reply
what is Economics and it important
Anita Reply
what is production
Anita
what is Economic
Anita Reply
what is the meaning of Economic
Anita
economics is a science which studies human behaviour as a relationship between ends and scarce means which have alternative uses
Boso
I don't know.
natchanan
u don't
Ssali
@ Boso thanks for the definition ✌
Raewyn
boso u r too much u try
Liambee
ya nyc
Ssali
Thanks kk
Anita
pls can I ask more questions
Anita
what is production
Anita
production is creation of goods and services
George
what is macroeconomics and microeconomics
Anita
macroeconomics deals with larger economic units such as GDP,GNP,employment while microeconomics deals with smaller economic units such firm and household
George
Thanks
Anita
Explain the ff Scarcity Ends Demand Supply Choice Scale of preference
Anita
macroeconomics deals with larger economic units such as GDP,GNP,employment while microeconomics deals with smaller economic units such firm and household
George
Gross Domestic product...it represent the total value of the products produced within the country including foreign industries
George Reply
what is products
Anita
what are the favourable demand
Odia Reply
list of climate that affect demands
Odia
What is two major forms of international trade?
Musa Reply
What is Economics and why it is important
Abdul Reply
De ans,Economics is the study of women behavior as a relationship between end and scared mean which have alternative uses.
Anita
What is Inflation
Abdul Reply
More money = more consumers, more consumers = lessen the product, less product = high price, high price = inflation
TuroN
is it definition
Odia
why price and quantity increase
Otuu Reply
condition under which price and quantity will be increased at the same time
Otuu
factors that hinders mobility of labour
Dennis Reply
what is scarcity
Adams Reply
why are people still unemployed in this economy we live in
Joyce Reply
why are people still unemployed in this economy
Joyce
Because of high technology
Innocent
Due to low government expenditure, the state does not have money to invest in new projects that can result in more job opportunities.
Young
good afternoon all, what are the examples of development projects Pls?
James
I 'm not together with him, when we say government expenditure mean there is recession for her economic country. That why many people still unemployed in this economy we live in, it mainly depend for two phases like Natural hazards and human activities.
Innocent
For the first answer I was responded we are concerns to intensive technology in the whole world it lead to reduce of many workers.
Innocent
wat does the abbreviation ppc mean?
Tumiso
I would like to give you ideas so that you get well how can give answer to this question dears. Attempt to know these words and what these means; Deficit, Surplus and Balanced budget.
Innocent
ppc mean pay -per-click known as search engine marketing
Innocent
i found it ppc means production possibility curve
Tumiso
in economic is that true according to your answer, however about of Marketing is that Pay Per Click.
Innocent
how is inflation, output gap relate to monetary policy
Mary Reply
Difference between extinct and extici spicies
Amanpreet Reply
While the American heart association suggests that meditation might be used in conjunction with more traditional treatments as a way to manage hypertension
Beverly Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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?

Ask