teach-ict.com logo

THE education site for computer science and ICT

2. String assignment and storage.


The first step in using strings is to get the program to recognise which variables are meant to be strings. This is done by putting the characters you want in the string in between a pair of speech marks, like this:

MyLargeString = "Hello this is a string"

Strings can have numbers inside of them, but the number is now handled as just another set of characters.

You can't carry out any calculations on numbers in a string without first converting it into a different data type, like an integer or floating point number. For example a telephone number can be stored in this way as no maths is likely to be carried out on it.

MyTelephoneNumber = "01926111111"

Strings can be input by the user and stored in a string variable.

For example the pseudocode :-

                  YourName = input('Please enter your first name')

This displays a prompt on the screen asking the user to enter a string. When they do, it is stored as the YourName variable.


Each character in a string is stored as a single byte. If there is more than one character in the string, the group is given a name and handled in the program as a single item.

For example

MyLargeString = "Hello this is a string"

MyLargeString is handled as one variable. It takes 22 bytes of memory to store all of the characters in this string (remember that blank spaces take up as much space as any other character).


Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is a string variable?