@@ -62,8 +62,9 @@ worked just fine. Later we'll learn what `(3, 14)` is.
6262
6363## Comments
6464
65- We can also type a ` # ` and then whatever we want after that. These bits
66- of text are known as ** comments** , and we'll find uses for them later.
65+ ** Comments are text that does nothing.** They can be created by typing a
66+ ` # ` and then some text after it, and they are useful when our code would
67+ be hard to understand without them.
6768
6869``` python
6970>> > 1 + 2 # can you guess what the result is?
@@ -74,7 +75,7 @@ of text are known as **comments**, and we'll find uses for them later.
7475Again, I put a space after the ` # ` and multiple spaces before it just to
7576make things easier to read.
7677
77- If we write comment on a line with no code on it, the prompt changes
78+ If we write a comment on a line with no code on it, the prompt changes
7879from ` >>> ` to ` ... ` . To be honest, I have no idea why it does that and I
7980think it would be better if it would just stay as ` >>> ` . The prompt goes
8081back to ` >>> ` when we press Enter again.
@@ -85,6 +86,56 @@ back to `>>>` when we press Enter again.
8586>> >
8687```
8788
89+ ## Strings
90+
91+ Strings are small pieces of text that we can use in our programs. We can
92+ create strings by simply writing some text in quotes.
93+
94+ ``` python
95+ >> > ' hello'
96+ ' hello'
97+ >> > ' this is a test'
98+ ' this is a test'
99+ >> >
100+ ```
101+
102+ String's can also be written using "double quotes" instead of 'single quotes'.
103+ This is useful when the string needs to contain single quotes.
104+
105+ ``` python
106+ >> > " hello there"
107+ ' hello there'
108+ >> > " it's sunny"
109+ " it's sunny"
110+ >> >
111+ ```
112+
113+ It's also possible to add single quotes and double quotes into the same
114+ string, but most of the time we don't need to do that so I'm not going
115+ to talk about it now.
116+
117+ It doesn't matter which quotes you use when the string doesn't need to
118+ contain any quotes. If you think that one of the quote types looks nicer
119+ than the other or you find it faster to type, go ahead and use that.
120+
121+ Strings can be joined together easily with ` + ` or repeated with ` * ` :
122+
123+ ``` python
124+ >> > " hello" + " world"
125+ ' helloworld'
126+ >> > " hello" * 3
127+ ' hellohellohello'
128+ >> >
129+ ```
130+
131+ Note that a ` # ` inside a string doesn't create a comment.
132+
133+ ``` python
134+ >> > " strings can contain # characters"
135+ ' strings can contain # characters'
136+ >> >
137+ ```
138+
88139## Using Python as a calculator
89140
90141``` diff
@@ -146,7 +197,9 @@ enough when you need to calculate something.
146197- We can enter any Python commands to the interactive ` >>> ` prompt, and
147198 it will echo back the result.
148199- ` + ` , ` - ` , ` * ` and ` / ` work in Python just like in math.
149- - Pieces of text starting with a ` # ` are comments.
200+ - Pieces of text starting with a ` # ` are comments and pieces of text in
201+ quotes are strings.
202+ - You can use single quotes and double quotes however you want.
150203
151204***
152205
0 commit comments