Storing text
Exercise 1:
So far, we have only worked with numbers. Now we will work with text as well.
In [1]: first = 'Emily'
In [2]: last = "Smith"
In [3]: name = first + " " + last
In [4]: name
Exercise 2:
What do the following statements do?
In [5]: name[0]
In [6]: name[3]
In [7]: name[-1]
Exercise 3:
Is it possible to include the following special characters in a string?
Ä á @ ? & * \ / " '
Exercise 4:
What does name
contain after the following statements? Explain the code.
In [8]: name = ""
In [9]: anna = "Anna"
In [10]: name = anna[0] + name
In [11]: name = anna[1] + name
In [12]: name = anna[2] + name
In [13]: name = anna[3] + name
In [14]: name