Lesson goal: Learning about strings

Previous: Find sin(x) by adding numbers | Home | Next: The length of a string

In a previous lesson we alluded to "literal text" in programming. By this we meant text in a program that is always taken on face value; verbatim as it stands. Taken literally by the computer with no further processing. Text such as this in programming is often referred to as a string. Note the key element here is what the computer outputs in response to print(2+2) and print("2+2"). The former yields 4, the latter yields 2+2. Do you know why?

A string is programming is a "string" (or sequence, series, succession) of characters, tacked together, to form a word or a sentence. A string is usually enclosed in double or single quotes. The double (or single) quotes are special, as they tell the computer to not evaluate or interpret what's inside of the quotes in any way...just take it as it stands. This is the nature of a string.

This lesson will show you what it means to "add" two string together, often called "concatenation." The concatenation operator is two dots put together like this: ...
string1 .. string2
Move the mouse over a dotted box for more information.

The result of the .. operation on string1 and string2 is the concatenation of the two strings.

Now you try. Fill in some strings into the a= and b= lines.

Type your code here:


See your results here: