-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple03.html
More file actions
58 lines (55 loc) · 1.94 KB
/
Copy pathsimple03.html
File metadata and controls
58 lines (55 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
layout: base.html
title: Simple HTML - Doing sums
---
<section class="side-by-side">
<canvas class="game right" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
<div>
<article>
<h1>Doing sums</h1>
<p>The command <code class="command">PRINT</code>, followed by a sum, tells the computer to work out the sum and put the answer on
the screen. Try the <code class="command">PRINT</code> commands shown below. The commands have no line
numbers, so the computer carries out each one straight away.</p>
<pre>
PRINT 2+2
PRINT 2*3
PRINT 6/2
PRINT 2-4
</pre>
<center><img src="{{ base_uri }}/img/usborne/simple-basic/img/04sums.jpg"></center>
<h2>Hours program</h2>
<p>This program makes the computer
work out the number of hours in a year.
Line 30 does the calculation. It multiplies the number of days in a year, by the number of hours in a day.</p>
<p>Let’s type it in and <code class="command">RUN</code> it now.</p>
<pre>
NEW
10 CLS
20 PRINT "THERE ARE "
30 PRINT 365*24
40 PRINT "HOURS IN"
50 PRINT " A YEAR"
RUN
</pre>
<center><img src="{{ base_uri }}/img/usborne/simple-basic/img/04hours.jpg"></center>
<p>Notice that there are spaces in the strings we're printing above, which look like they're intended for the message
to be printed out on one line, but because <code class="command">PRINT</code> outputs on a new line, the spaces
aren't really necessary.
</p>
<p>You can modify a <code class="command">PRINT</code> so it doesn't end with a new line by putting a semicolon after it. Try editing
your program using <code class="command">EDIT</code> followed by a line number, to add semicolons to the end of lines
20, 30 and 40, then run it again.</p>
<p>Your code should end up looking like this:</p>
<pre>
10 CLS
20 PRINT "THERE ARE ";
30 PRINT 365*24;
40 PRINT "HOURS IN";
50 PRINT " A YEAR"
</pre>
<footer>
<a href="{{ base_uri }}/simple04" class="button">Next</a>
</footer>
</article>
</div>
</section>