# 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 = ');
printNumber(3);
print(' meters');
printNewLine();
print('width = ');
printNumber(2);
print(' meters');
```

### Why?

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');
printNewLine();
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:

• First, prints some text, called the prefix, exactly like the command print.
• Second, prints a rounded value just like printNumber.
• Third, prints some text, called the suffix, again like the print command.
• Fourth, skips to the next line as printNewLine does.

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

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

Would output:

`prefix5suffix`

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

0ptions

Go on input

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

Edit: Runtime          View: Starter Suggestion

To runtime:

Storage:

Editor width: Normal Wide

### And....

Next tutorial: Simple arithmetic

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

### Other sites you may find interesting

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.

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.

Custom Search

Name:
Domain:

Name
0

Name:
Name
0