Strings – weeks 1 and 2

“Typing is no substitute for Thinking.”

Handout: 1_Intro_1_strings.pdf

Training mission

Click on the student template. The teacher will help us fill it out.

Advanced (show me):A string is a sequence of zero or more characters surrounded by quotes, e.g.,


string
“Washington”
“134”
“david34”
“Today is a great day!”
”    ”
“”


comment
an alphabetic string (only letters)
a numeric string (only numbers)
an alpha-numeric string (only letters and numbers)
a general string
a string of spaces
the empty string (nothing in it)


Most characters that we use in strings are visible, like letters, digits, and punctuation marks. However, strings can also contain invisible characters. The most common invisible characters are:

  • the space, created with the space bar; it leaves a blank before writing the next character.
  • the new line, created typing \n; writes the next character on the next line
  • the tab, created typing \t; jumps to the next fix column position

3rd grade – It’s all about me

Work it out

Please tell us a bit about yourself by filling the strings. The following is
a sample for another student:

Hello

My name is Anakin. I am 10 years old and am in 10 grade,
in Obi-Wan’s class, at the Jedi Temple.

My favorite food is black beans and rice and my favorite
ice cream flavor is cookie dough.

Jedi Temple. Image from http://www.rossiters.com/swo/aotc_uf41-50.html

Answer: Show it to me


4th grade – Scrambled secret message

Work it out

Here is a scrambled message. Our best decoder came up with the following message:

r thig is nking.no subte fostituTypin

but somehow we do not think he got it right because it does not make sense.. it is not even English! Please, help us recover the message correctly

girl-wth-computer

Hint: look at the quote at the top of this webpage.

Answer: Show it to me


5th grade – Robotics section cafeteria

Work it out

We hired a programmer to write our menu but unfortunately he is presently at the hospital with food poisoning. We are hoping you can finish the program that he started. At the moment all we have is this:

Half-made cafeteria menu

Half-made cafeteria menu

and.. well.. everybody is sick and tired of only burger and fries. Please, please… would you finish the menu? With the items in alphabetical order, please?

cheeseburger-34314_640

Answer: Show it to me

Kudos if were able to use the ‘\t’ character, a.k.a. a ‘tab’, to align the items vertically.


6th grade – The pair-up game

Work it out

Hum.. Megatron is the robot from Star Wars.. or is it from Star Trek? I can’t remember… I need help!

Finish the list of famous robots paired up with the T.V. show or movie in which they appeared. So far this is what we have:

pair-up-game

Are we missing any? Add any pair that you can think of.

robot-788936_640

Answer: Show it to me

Kudos if you are able to align the columns vertically