<< Chapter < Page Chapter >> Page >
  • Changes to the next costume in the list. (In this program the list contains two costumes.)
  • Moves ten steps forward relative to its own orientation.
  • Pauses for 0.1 seconds.
  • Turns fifteen degrees counter-clockwise around its own center of rotation.

No screen shot of the output

Because this program is animated, a screen shot of the Stage wouldn't impart much information so I won't show you one. Basically, it would look very similarto Image I without the thought bubble. You can copy the code from Image C and insert it into your own program. Also, the program has been posted online so that youcan run it from there. (See the link to the online version in Resources .)

The program named ForeverLoop02

This program illustrates another usage of a forever block with an embedded if block. The behavior of this program is very similar to a program that I explained in anearlier module using the repeat block. However, there are major differences between the forever/if combination of blocks and the repeat block. Some of those differences are illustrated in Image D , which shows a repeat block at the top and a forever block with an embedded if block near the center.

Image d. comparison between repeat and forever/if blocks.

Missing image.
Image D. Comparison between repeat and forever/if blocks.

Comparison between repeat and forever/if blocks

One of the major differences is the shape of the blocks that can be dropped into the pockets on the repeat block and the if block.

The blocks with the rounded ends in the upper half of Image D , which generally produce numeric results, cannot be droppedinto the pocket with the pointed ends on the if block. The if block requires a boolean value of true or false.

However, the blocks with the rounded ends can be dropped into the pocket with rounded ends on the repeat block, which requires a numeric value.

The blocks with the pointed ends in the lower half of Image D can be dropped into the pocket on the if block. Generally speaking, those blocks produce a boolean result of true or false.

Curiously, the blocks with the pointed ends can also be dropped into the pocket with the rounded ends on the repeat block. That pocket needs a numeric value to specify how many times its embedded code will beexecuted. My unconfirmed guess is that when one of the boolean blocks with the pointed ends is dropped into a repeat block, a false value is treated as 0 and a true value is treated as 1.

No drop-in required for a repeat block

The repeat block doesn't require that any other block be dropped into the pocket to make it fully functional. All that is required isthat a literal value be entered into the pocket, or that the default literal value be accepted. Used in this way, the repeat block will cause the code inside the block to be executed a number of times matching the literal value.

A drop-in is required for the if block

On the other hand, the if block requires that another block, which evaluates to either true or false, bedropped into the pocket to make it functional.

The forever block is more versatile than the repeat block

In this program, I used a counter variable in conjunction with a less than block to produce a boolean result, thus causing the behavior of the forever/if block combination to be similar to the behavior of a repeat block. However, the forever block is much more versatile. The forever/if combination can be used to execute a seriesof code blocks on the basis of any block that you can construct that will evaluate to true or false.

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
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