Emojicode π‘ Strings
Strings are words or pieces of text that the computer treats as a single item. They provide a way to store something like a word, sentence, or whole paragraph.
Technically speaking, a string is a sequence of characters. It can be of any length and contain any letters, numbers, symbols, or spaces as long as they are surrounded by π€βs.
Syntax
Here are four different strings in Emojicode:
π€This is a string!π€π€This is also a string!!!π€π€1337π€π€πππ€
Itβs important to distinguish between strings and the rest of the code in our programs. Every part of a program is made up of characters, but strings are the parts we intend to keep as dataβnot as instructions to be executed by the computer.
Example
Hereβs a full program that print out two strings:
π ππ π€2020...π€βοΈπ π€That was a crazy year.π€βοΈπ
String Interpolation
String interpolation can be used to construct a string from a mix of constants, variables, and others by including their values inside a string literal.
In Emojicode, to insert a value into a string using string interpolation, we can write the variable inside two π§²s and it will print its value.
Suppose we have a constant named height with a value of 3000, and we want to use string interpolation to print out a fun fact:
3000 β‘οΈ heightπ π€Alex Honnold climbed El Capitan, which is π§²heightπ§² feet, without a rope!π€βοΈ
It will output:
Alex Honnold climbed El Capitan, which is 3000 feet, without a rope!
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Emojicode on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- π Learn about Emojicode, a programming language that consists of emojis! π
- Beginner Friendly.1 hour