Skip to content

Commit

Permalink
Add more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Aug 8, 2016
1 parent e104274 commit 9db8ee7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ probably want to read
This tutorial uses Python 3. Python 2 is getting outdated all the time,
and more and more projects are moving to Python 3. There are a few
popular libraries that don't support Python 3 that well at the time of
writing this, but you don't need to worry about that just yet. They will
probably support Python 3 by the time you've learned the basics and you
may actually need them.
writing this, but you don't need to worry about that just yet. They
will probably support Python 3 by the time you've learned the basics
and you may actually need them.

Here's a list of chapters in this tutorial. Read them one by one in the
order they are listed. **If you jump to a chapter without reading
Expand Down
35 changes: 20 additions & 15 deletions if.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,50 @@

### Using if statements

Back in chapter 2, we learned what the boolean values True and False are.
Now we know what True and False are.

```py
>>> 1 == 1
True
>>> 1 == 2
False
>>>
```

We also learned how to assign them to variables.

```py
>>> its_raining = True
>>> its_raining
True
>>>
```

But what if we want to execute different code depending on something? That's when `if` comes in.
But what if we want to execute different code depending on something?
That's when `if` comes in.

```py
>>> its_raining = True
>>> if its_raining:
print("It's raining!")


... print("It's raining!")
...
It's raining!
>>> its_raining = False
>>> if its_raining:
print("It's raining!") # nothing happens
... print("It's raining!") # nothing happens
...
>>>
```

The prompt changed from `>>>` to `...`. It meant that Python was
expecting me to keep typing. When I was done, I just pressed Enter
twice. My code was execute and the prompt was restored to `>>>`.

>>>
```
At this point it's easier to put your code into a file and use it
there. If you use IDLE, go to File at top left and select New File, or
just press Ctrl+N.

![New File in IDLE](idle-new.png)

After typing the line with print we need to press Enter twice to actually run the code we wrote. IDLE also indents everything we want to run if it's raining.
If you are not using IDLE, open whatever editor you have installed, or
install

At this point it's easier to put your code into a file and use it there. The file's content would be like this:
The file's content would be like this:

```py
its_raining = True
Expand Down

0 comments on commit 9db8ee7

Please sign in to comment.