Tutorial 1

⌨️

Input Output

9618 A-Level


Inputting and outputting data is an essential part of any program. The following introductory activities will walk you through some simple examples:

1

Hello World

Let's see how to output the classic "Hello World" to the terminal/console

OUTPUT "Hello World"

When inputting, we will need to assign to a variable - as such, you may wish to read the data types tutorial

2

Person Details

Ask the user to enter 3 bits of information of various data types, then output a sentence to the user - e.g.

  • name
  • age
  • height

An example sentence could then be "Dumbledore is 715 years old and is 1.85m tall"

DECLARE name : STRING DECLARE age : INTEGER DECLARE height : REAL OUTPUT "Enter person's name:" INPUT name OUTPUT "Enter ", name, "'s age:" INPUT age OUTPUT "Enter ", name, "'s height in meters:" INPUT height OUTPUT name, " is ", age, " years old and is ", height, "m tall"

3

Salutations

For different levels of formality, we often want to greet people in different ways - have the user enter their title (Dr, Mr, Mrs, Miss etc), first name & last name, then display greetings in various levels of formality - e.g.

  • Dear Lord Riddle
  • Hi Tom
  • Signed: Riddle, Tom
DECLARE firstname, lastname, title : STRING OUTPUT "Enter your title:" INPUT title OUTPUT "Enter your firstname:" INPUT firstname OUTPUT "Enter your lastname:" INPUT lastname OUTPUT "Dear ", title, " ", lastname OUTPUT "Hi ", firstname OUTPUT "Signed: ", lastname, ", ", firstname