<< Chapter < Page Chapter >> Page >

In addition, I used the pull-down list on each of six blocks to select the name of the variable to which each block applies. (Note that each of those six blocks refers either to Counter or counter .)

Image 5. the finished program.

Missing image.
Image 5. The finished program.

Behavior of the program

Click the green flag

The program contains three scripts. Each script remains silent until a specific event occurs. As the label on the uppermostblock in the top programming script in Image 5 indicates, the code in the top script in Image 5 is executed once each time the user clicks the green flag shown in the upper right of Image 1 . This code causes the values stored in each of the two variables to be set to zero. This, in turn causes thevariable displays in the Stage area to each show a value of 0.

Press the space bar

Because of the top block in the middle script reads "when space key pressed" , the code in the middle script is executed once each time the user presses the space bar.

The pull-down list on this block allows you to select among the keys on the keyboard with the space bar being the default.

One of the orange programming blocks in the middle script causes the value of the variable named Counter to change by +1 when the space bar is pressed. The other orangeprogramming block causes the value of the variable named counter to change by +5 when the space bar is pressed.

In other words, repetitively pressing the space bar causes the Counter variable to count up in increments of one and causes the counter variable to count up in increments of five.

Click the mouse on the Stage

Because of the top block in the bottom script reads "when stage clicked" , the code in the bottom script in Image 5 is executed once each time the user clicks the mouse in the large white Stagearea shown in Image 1 .

The bottom two blocks in this script are the same as the bottom two blocks in the middle script except that the algebraic signs on the two literal values are minus instead of plus.

The absence of a "-" character causes a literal value to be positive. A "+" character is notrequired for positive literal values.

Repetitively clicking the mouse in the Stage area causes the Counter variable to count down in increments of oneand causes the counter variable to count down in increments of five.

Event-driven programming

The ability to write programs that cause certain operations to occur in response to events (such as pressing the space bar and clicking the mouse on the Stage) is often referred to as event-driven programming.

It is easy to write event-driven programs in Scratch. On the other hand, writing event-driven programs is not easy in languages such asJava, C#, and C++. You need quite a lot of programming knowledge to write event-driven programs in those languages.

It is useful to give programming students a taste of event-driven programming early, if for no other reason than the factthat it tends to make programming more interesting.

Example blocks with pointed ends

The blocks shown in Image 6 are not used in this program. They are shown in this module to illustrate blocks with pointed endsreferred to earlier .

Questions & Answers

anyone know any internet site where one can find nanotechnology papers?
Damian Reply
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.
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
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
characteristics of micro business
for teaching engĺish at school how nano technology help us
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
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
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.
what is the actual application of fullerenes nowadays?
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.
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.
is Bucky paper clear?
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
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.
Do you know which machine is used to that process?
how to fabricate graphene ink ?
for screen printed electrodes ?
What is lattice structure?
s. Reply
of graphene you mean?
or in general
in general
Graphene has a hexagonal structure
On having this app for quite a bit time, Haven't realised there's a chat room in it.
what is biological synthesis of nanoparticles
Sanket Reply
what's the easiest and fastest way to the synthesize AgNP?
Damian Reply
types of nano material
abeetha Reply
I start with an easy one. carbon nanotubes woven into a long filament like a string
many many of nanotubes
what is the k.e before it land
what is the function of carbon nanotubes?
I'm interested in nanotube
what is nanomaterials​ and their applications of sensors.
Ramkumar 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
Berger describes sociologists as concerned with
Mueller 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?