Strings
Anything that is surrounded by quotation marks is called a string
. This is how a computer represents words or sentences. For example, "a"
, "2"
, "banana!"
, and "Hello World"
are strings, but 2
and Hello World
are not strings, because the quotation marks are missing.
You can combine many strings together using the +
sign.
For example:
"Apple" + "Pineapple"
produces the string"ApplePineapple"
."Nuevo" + " " + "Foundation"
produces the string"Nuevo Foundation"
.
What if you wanted to combine your first and last name? How would you do that?
Activity 2
Delete all the print
statements in your code. Start your code with the line print("Nuevo" + " " + "Foundation")
If you run it, you should get the following output:
Nuevo Foundation
Let’s try and find two more ways to print the string "Nuevo Foundation"
using two plus (+
) symbols in each print
statement. Once you make this work, you should have “Nuevo Foundation” printed out 3 times. In other words, your console should look like this after you press run:
Nuevo Foundation
Nuevo Foundation
Nuevo Foundation
Hint: The strings that you combine do not have to be real words! For example, "Ap" + "ple"
will produce the string "Apple"
. Ask for help if you are confused.