Getting StartedGiving Commands to ObjectsPrograms 1Programs 2CalculatorVariables: Remembering StuffStrings 1Strings 2InputIfWhile: Loops and Repeating ThingsRandom Numbers and ChooseFSM: The Finite State Machine
Strings 1

People talking to each other, but only using numbers

So far, you've been working mostly with numbers in your programs. If you want to use words in a program, you need something called a string.

show("hello world!"); with quotations marks marked. Perhaps with inset window showing the result

A string is bunch of letters or words put between quotes. You can have symbols (except for the \ and ") and numbers in between the quotes as well. If you try to show a string, everything except for the quotes will be shown.

actingbot.say(hello);  "hello" is not defined.

It's important to have quotes at the beginning and end of the string. Computers aren't very smart and can get easily confused. It will think you are trying to use a variable!

actingbot.say("My name is actingbot"); actingbot.say(55);

On the left, there is a Program Area where you can try showing different strings on the screen. There is also a special robot called the actingbot who can do some acting. The actingbot object understands the say command. If you give the actingbot a string to say, the actingbot will say it. You can also get the actingbot to say numbers.

r = "row"; actingbot.say(r); actingbot.say(r); actingbot.say(r); actingbot.say("your boat."); or maybe weather="rainy";

Strings can be put inside variables just like numbers.

show("apple" + " juice");  fruit="orange"; show(fruit + " juice"); show("5" + "6"); with results, also arrow showing result is not 11

Unlike numbers, you can't do math with strings. If you try to add strings together, the two strings get joined together. Be careful when you have numbers inside a string! When you add them together, the two strings get joined together and not added together.


Programming Basics

Programming Basics: Beginners

E-mail | About | Privacy Policy