<< Chapter < Page Chapter >> Page >

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 so 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 4 are not used in this program. They are shown in this module to illustrate blocks with pointed endsreferred to earlier .

Image 4. example blocks with pointed ends.

Missing image.
Image 4. Example blocks with pointed ends.

Run the program

I encourage you to use the information provided above along with the Scratch 2.0 programming interface shown in Image 1 to write and run 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.

A copy of this program has been posted online for your review.

I also encourage you to write the programs described below.

Student programming projects

The following projects are designed to:

  • Help the student retain the knowledge gained by studying the module.
  • Require the student to think beyond the material presented in the module by requiring the student to answer the question "How do I ...?"

Project 1

Begin with the program named Variable01 and modify it to create a new program named Variable02 . Modify the original program in such a way that pressing the space bar five times in succession, (after clicking the green flag to set both variables to zero) , will cause the displayed values of the variables named Counter and counter to be as shown in Image 5 .

Image 5. output from project 1.

Missing image.
Image 5. Output from Project 1.

Having reached that point, clicking the mouse five times in succession in the Stage area will cause the displayed values of the variables named Counter and counter to be as shown in Image 6 .

Image 6. output from project 1.

missing image
Image 6. Output from Project 1.

A copy of this program is posted online for your review.

Project 2

You should successfully complete Project 1 before attempting this project. Begin with the program named Variable01 and modify it to create a new program named Variable03 . Modify the original program in such a way that pressing the space bar five timesin succession, (after clicking the green flag to set both variables to zero) , will cause the displayed values of the variables named Counter and counter to be as shown in Image 7 .

Image 7. output from project 2.

Missing image.
Image 7. Output from Project 2.

Questions & Answers

what is mutation
Janga Reply
what is a cell
Sifune Reply
how is urine form
Sifune
what is antagonism?
mahase Reply
classification of plants, gymnosperm features.
Linsy Reply
what is the features of gymnosperm
Linsy
how many types of solid did we have
Samuel Reply
what is an ionic bond
Samuel
What is Atoms
Daprince Reply
what is fallopian tube
Merolyn
what is bladder
Merolyn
what's bulbourethral gland
Eduek Reply
urine is formed in the nephron of the renal medulla in the kidney. It starts from filtration, then selective reabsorption and finally secretion
onuoha Reply
State the evolution relation and relevance between endoplasmic reticulum and cytoskeleton as it relates to cell.
Jeremiah
what is heart
Konadu Reply
how is urine formed in human
Konadu
how is urine formed in human
Rahma
what is the diference between a cavity and a canal
Pelagie Reply
what is the causative agent of malaria
Diamond
malaria is caused by an insect called mosquito.
Naomi
Malaria is cause by female anopheles mosquito
Isaac
Malaria is caused by plasmodium Female anopheles mosquitoe is d carrier
Olalekan
a canal is more needed in a root but a cavity is a bad effect
Commander
what are pathogens
Don Reply
In biology, a pathogen (Greek: πάθος pathos "suffering", "passion" and -γενής -genēs "producer of") in the oldest and broadest sense, is anything that can produce disease. A pathogen may also be referred to as an infectious agent, or simply a germ. The term pathogen came into use in the 1880s.[1][2
Zainab
A virus
Commander
Definition of respiration
Muhsin Reply
respiration is the process in which we breath in oxygen and breath out carbon dioxide
Achor
how are lungs work
Commander
where does digestion begins
Achiri Reply
in the mouth
EZEKIEL
what are the functions of follicle stimulating harmones?
Rashima Reply
stimulates the follicle to release the mature ovum into the oviduct
Davonte
what are the functions of Endocrine and pituitary gland
Chinaza
endocrine secrete hormone and regulate body process
Achor
while pituitary gland is an example of endocrine system and it's found in the Brain
Achor
what's biology?
Egbodo Reply
Biology is the study of living organisms, divided into many specialized field that cover their morphology, physiology,anatomy, behaviour,origin and distribution.
Lisah
biology is the study of life.
Alfreda
Biology is the study of how living organisms live and survive in a specific environment
Sifune
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