Skip to content

Commit df1066c

Browse files
committed
some day gonna drop the way of the program thingy
1 parent f7fe875 commit df1066c

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

TODO.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ This tutorial is not complete. It still needs:
3535
- "What the heck is this?" section for stuff i haven't talked about
3636
- regexes
3737

38+
- add a screenshot about geany's running settings to
39+
basics/editor-setup.md
40+
3841
***
3942

4043
If you have trouble with this tutorial please [tell me about

basics/getting-started.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
7475
Again, I put a space after the `#` and multiple spaces before it just to
7576
make 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
7879
from `>>>` to `...`. To be honest, I have no idea why it does that and I
7980
think it would be better if it would just stay as `>>>`. The prompt goes
8081
back 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

Comments
 (0)