3 Strings are Text


Strings are a data type[1] that is used to store text.

Any data[3] the has characters (A-Z, a-z and other symbols like ! @ ‘ , . &) is a string[4], if it also has characters and numbers it will be stored as a string.

If it just has numbers it will be stored as a number.

It is really important to know what type of data you want to store.

Strings are always enclosed in a pair of ” ” or ‘ ‘

If you are going to have a ‘ in the text such as in don’t use the ” ” to enclose the string.

"In time they're going to be ok"

It is a good habit to be consistent with that you use to enclose the string.

You can write a multiple line string by enclosing it with “”” “”

"""Hello,
This string contains text that
is spread over
multiple
lines."""

The more you comment[2] your code the easier it is to understand and maintain.

You might remember what you are working on right now, but what happens when someone else looks at your code or you come back to it a week, month or a year later?

Terms definitions
1. data type. The format that a piece of data is stored in. It is important as you should only manipulate data that is of the same type. Examples of data types are integer, float, boolean, character, string, date / time.
2. comment. Disabling a block of source code by changing it into a comment. This technique is used for debugging or for testing the functionality of alternative versions of code.
3. data. Raw facts or figures without context or meaning. e.g. 1, “Boris”, False
4. string. A data type used to store text. Often enclosed in “” or ”