<< Chapter < Page Chapter >> Page >

Operands

According to the current jargon, operators operate on operands .

For example, in the following expression, the plus character is an operator while x and y are operands.

x + y

Assuming that x and y are numeric variables, this expression produces the sum of the values stored in the variables named x and y . The variable x would be called the left operand and the variable y would be called the right operand .

Expressions

Computer programs in many languages consist of statements, which in turn, consist of expressions. (Programming blocks substitute for statements in Scratch.)

An expression is a specific combination of operators and operands that evaluates to a particular result. The operands can bevariables, literals, or method calls. (Note that Scratch v1.4 didn't support methods. However, Scratch 2.0 allows you to design and create yourown blocks, which helps to alleviate that deficiency.)

In your past experience, you may have referred to expressions by the names formulas or equations . Although formulas and equations are not exactly the same thing as expressions, they are close enough to help youunderstand what expressions are and how they are used.

Statements

A statement is a specific combination of expressions. The following is an example of a statement comprised of expressions in a text-based language such as Java, C++,or C#.

z = x + y;

Operationally, values are retrieved from the variables named x and y in the above statement. These two values are added together. The result is stored in (assigned to) the variable named z , replacing whatever value may previously have been contained in that variable.

The plus character (+) would commonly be called the addition operator or the concatenation operator, depending on the type of data stored in the variables named x and y . The equal character (=) would commonly be called the assignment operator in Java, Alice, C#, and C++, but wewill see in a future module that it is also used as a relational operator in Scratch.

A brief word about type

As a very crude analogy, you can think of variables as the pens at the animal shelter and think of type as the kinds of animals that reside in those pens. Dogs and cats aredifferent types of animals that don't usually coexist very well in the same pen. Therefore, they are normally put in different pens.

Similarly, different types of data don't coexist well in the same variable in type-sensitive languages. Therefore, in type-sensitive languages, there are very stringent rules as to the types of data that can be stored in each variable.

Scratch has two types of data that can be stored in a variable (numeric and string) . However, Scratch is not a type-sensitive language so type is not an issue in Scratch. (Scratch also has a semblance of a boolean type but it tends to take care of itself.)

Unary, binary, and ternary operators

Many programming languages provide operators that can be used to perform an action on one, two, or three operands. I believe that operators in Scratchare confined to only one or two operands.

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