Input, Output & String Handling Flashcards
All 12 cards in this deck
In AQA pseudo-code, how do you get a value from the keyboard and display a message that uses it?
e.g. ask for a name then greet the user
- Store the input in a variable:
name ← USERINPUT - Display the message with OUTPUT:
OUTPUT 'Hello ' + name
- Store the input in a variable:
What is a string conversion (casting)?
Converting a value from one data type to another, e.g.
STRING_TO_INT('25')converts the string '25' to the integer 25.Why does keyboard input often need converting before it is used in a calculation?
In most languages keyboard input is read as a string, so it must be converted to an integer or real (e.g. with
STRING_TO_INT) before arithmetic is done on it.Which AQA pseudo-code functions convert between strings and numbers?
STRING_TO_INTandSTRING_TO_REALconvert a string to a number;INT_TO_STRINGandREAL_TO_STRINGconvert a number to a string.In AQA pseudo-code, how do you join two strings together?
e.g. join
firstNameandsurnamewith a space between themWith the
+operator (concatenation):fullName ← firstName + ' ' + surnameIn AQA pseudo-code, how do you find the number of characters in a string?
e.g.
word ← 'computer'LEN(word), which gives8.What does
SUBSTRING(start, end, s)return in AQA pseudo-code?e.g.
SUBSTRING(3, 7, 'computer')The characters of
sfrom positionstartto positionend, with both included and positions counted from 0. Here it returns'puter'.What do
CHAR_TO_CODEandCODE_TO_CHARdo?e.g. given that the character code for 'A' is 65:
CHAR_TO_CODE('A')andCODE_TO_CHAR(66)CHAR_TO_CODEreturns the character code of a character andCODE_TO_CHARreturns the character for a code, giving65and'B'.True or false?
LENcounts spaces and punctuation when finding the number of characters in a string.True.
LENcounts every character, including spaces and punctuation, e.g.LEN('Hi, Sam')is 7.In AQA pseudo-code, how do you output more than one value in a single
OUTPUTstatement?e.g. a name and a score
Separate the values with commas:
OUTPUT name, scoreWhat does
POSITION(s, c)return in AQA pseudo-code?e.g.
POSITION('keyboard', 'b')The position of the first occurrence of the character
cin the strings, counting from 0. Here it returns 3.In AQA pseudo-code, how do you get a single character from a string?
e.g. the first letter of
nameUse
SUBSTRINGwith the same start and end position, counting from 0:SUBSTRING(0, 0, name)