<< 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 a market demand schedule
Blessed Reply
What is demand curve
mohamed Reply
Types of demand curve
mohamed
demand curve is a showing the aggregate of demand whether falling from right to the left in the table above
BULAMA
demand curve is the graphical representation of various quantities of a commodity bought at various prices
Blessed
What is the formula for calculating elasticity
Hafsat Reply
what is demand
Anefor Reply
demand is the quantity of commodity that consumers wil be able and wiling to buy at a given price at a given time
Delly
what is international trade?
Friday Reply
it is the exchange of goods and services across international borders.
Tweneboah
what is taxation
Eunice Reply
the definition of economic by Adam Smith
Geon Reply
Adam Smith define economic as the science of wealth
Hafsat
What is enconomics
mohamed
what is meant by pisp in economics?
Amara Reply
payment initiation service provider
Khuselo
what is demand
Joy Reply
demand
Demand refers to the consumers' desire to purchase goods at given prices. Demand can mean either demand for a specific good or aggregate demand for the total of all goods in an economy.
What is economc
Joseph Reply
What is economc
nahurira
What is Economic
Vicky Reply
What's the price index of consumption?
Pun Reply
what population
Hackman Reply
I think it's the sum total of people in a goegraphical area at a given time
Ruth
it refers to the number of people living in a particular area over a given period of time
Vanessa
decribe law of demand
Lovely Reply
the higher the price , the higher the quantity demanded
Ruth
what is economic growth
Metuge Reply
what is an economic system
Metuge
Economic system is the mechanism which deals with the production, distribution and consumption of good and services in a particular society
Happy
of course
Maesela
what is a weight
Maesela
What is a weight
mohamed
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




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