AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Plans before programs

Week 1 · 1.1 Pseudocode · 3 lessons
2

Asking and telling

Computing 8: Topic 1.1, pp. 9–26
GoalWrite INPUT and OUTPUT statements, use double quotation marks correctly and join items with a comma.
New words
INPUT · a command that stores what the user types in a variableOUTPUT · a command that shows data on the screenstring · text in double quotation marks, shown exactly as writtenconcatenation · joining two or more items to make one longer piece of text
Explanation

INPUT takes what the user types and stores it in a variable, so it always needs an identifier, for example INPUT name. OUTPUT shows data on the screen. Text that must appear exactly as written is a string, and it goes inside double quotation marks. Without the quotation marks, the computer reads the word as the identifier of a variable and shows the value stored in it. To show text and variables together you join them. Joining is called concatenation, and in our house style a comma does it. The comma adds nothing between the items, so put any spaces inside the quotation marks. Other styles use + or &, and both are valid too. In the picture the user types Nodira.

Pseudocode
1INPUT reader
2OUTPUT "Welcome, ", reader, "!"
Output
Welcome, Nodira!
Worked examples
StatementShown on the screen
OUTPUT teamEagles
OUTPUT "team"team
OUTPUT "Team: ", teamTeam: Eagles
OUTPUT team, teamEaglesEagles
Quotation marks decide what is shown. Here the variable team holds the text Eagles. The same word gives different output with and without quotation marks.
Pseudocode
1shelf ← "B"
2number ← "27"
3OUTPUT shelf, number
Output
B27
Concatenation joins strings into one. Two variables hold the strings B and 27, the shelf and the place of a library book. The comma puts them side by side with no gap, so the output is the code B27.
Pseudocode
1OUTPUT "Enter the book code:"
2INPUT code
3OUTPUT "Enter the reader's name:"
4INPUT reader
5OUTPUT reader, " has borrowed book ", code
Output
Enter the book code:
Enter the reader's name:
Kenji has borrowed book B27
A longer algorithm for a school library desk. The user types B27 and then Kenji. Notice that the spaces are inside the quotation marks.
Class activity

Colour hunt (no computer). Copy the four-line algorithm below onto paper. Use four colours: circle the command words in one colour, the variable identifiers in a second, the strings in a third and the commas that join items in a fourth. Algorithm: OUTPUT "Name of your stall?" / INPUT stall / OUTPUT "How many apples?" / INPUT apples / OUTPUT stall, " has ", apples, " apples". Compare with a partner. Then extend it with two lines that ask for the number of pears, and one line that shows it. If you have a computer or tablet, write the same program in Python.

Practice
1
The user types mango and then 3. Write what the algorithm shows on the screen.
Pseudocode
1INPUT fruit
2INPUT kilos
3OUTPUT "You chose ", fruit
4OUTPUT kilos, " kg"
2
This algorithm has two mistakes. Find them and write the corrected version.
Pseudocode
1OUTPUT "How many tickets?"
2INPUT
3OUTPUT You bought, tickets
3
Write pseudocode that asks for a team colour and a number of goals and then shows a sentence such as Team blue scored 4 goals.
4
The variable total holds 45. Explain the difference between OUTPUT "total" and OUTPUT total.