EZ Math Movie, Tutorials, Printing, Printing Text and Numbers

Math statements

Often we want to print statements like this:

length = 3 meters
width = 2 meters

To do this we would use a combination of print, printNumber, and printNewLine. It looks like this:

print('length = ');
print(' meters');
print('width = ');
print(' meters');


At first it might look like this approach is a bit too much work. Why not, for example, just write code like this:

print('length = 3 meters');
print('width = 2 meters');

It is true that the above code would produce the same output. So why bother printing the numbers separately? The reason for this will become clear as we move into the following tutorials where we will see that these numbers can be replaced with variables that have changing values and need to be printed out this way.

Here we are simply showing the mechanics of printing text and numeric values on the same line.

All together now.

These types of statements can be easily printed with the command printStatement, which does four things:

Let's assume a variable x holds a value of 5. Then this line:

printStatement('prefix', x, 'suffix');

Would output:


You can skip the suffix. So this:

printStatement('x = ', x);

Would print:

x = 5

Running the example program

This example shows how to print statements that include numeric values.

The example program

Angle measurement: Degrees Radians

Go on input

Sorry, apparently this browser does not support HTML 5 canvas tag graphics.

Edit: Runtime          View: Starter Suggestion

To runtime:


Editor width: Normal Wide








Next tutorial: Simple arithmetic


Here are some links to related articles at EZ Programing Demos:

Printing the value of a variable

Printing letters and variable values

Combining printing methods

All contents of EZ Math Movie are copyrighted: Copyright 2011, Edward A. Zobel. All rights reserved.

Other sites you may find interesting

Zona Land Education Like Math and Physics?

Zona Land Education offers explanations, diagrams, and animations on these topics.
And it is all presented in a clear and casual manner.

Here is the link: zonalandeducation.com

EZ Programing Demos Want to learn about programing computers?

EZ Programing Demos has an animated, slow motion, interactive programing language demonstrator.
The site presents basic ideas at a beginner's level.

Here is the link: ezprogramingdemos.com

Custom Search