Skip to content
Game 1 Unit 2 of 7 1 hr learning time

Building a Sentence

Two more inputs and a sentence that uses all three — the words start combining.

29% of Story Builder

One question is a greeting. Three questions is a sentence.

  10 BORDER 0: PAPER 0: INK 7: CLS
  50 INPUT "What is your name? "; n$
  60 INPUT "Name an adjective: "; a$
  70 INPUT "Name an animal: "; b$
 130 PRINT
 140 PRINT n$; " met a "; a$; " "; b$

Two new lines slotted into the gap: line 60 asks for an adjective, line 70 asks for an animal. Line 130 prints a blank line (spacing), and line 140 builds a sentence from all three answers.

Run it. Type "Dave", "grumpy", "penguin". The screen shows:

The Spectrum screen showing: Dave met a grumpy penguin
Three answers, woven into a sentence.

Try "enormous" instead of "grumpy" — the sentence reads "a enormous". The code always prints "a" regardless of what follows. Fixing that would need more logic than the story needs right now.

What changed

Lines 10 and 50 are untouched — the same setup and name question from unit 1. The new lines slot in at 60 and 70 (in the gap between 50 and 130). Line 130 changed from PRINT "Hello, "; n$ to just PRINT (a blank line). Line 140 is new.

Three variables now: n$ (name), a$ (adjective), b$ (animal). The semicolons in line 140 — PRINT n$; " met a "; a$; " "; b$ — glue five pieces onto one line: the name, fixed text, the adjective, a space, and the animal. (The semicolon join is the one from Meet BASIC, now building a sentence.)