Skip to content

Commit f66172d

Browse files
Merge pull request #394 from Hamatti/fix-python-if-else-tutorial
Add a declaration for variable number.
2 parents ec0c66e + dd02188 commit f66172d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

python/lesson2/tutorial.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ making.
1010

1111
Python allows us to store data in something called variables so that we are
1212
able to use this data at a later point. To place an item in a variable we give
13-
it a name then set its value.
13+
it a name then set its value.
1414

1515
Now in the REPL type:
1616

@@ -34,7 +34,7 @@ Now in the REPL type the following:
3434
>>> costs = 200
3535
>>> profit = revenue - costs
3636

37-
Now type `profit` to see the results of this calculation.
37+
Now type `profit` to see the results of this calculation.
3838

3939
Now work out the cost of running a codebar workshop if 60 people turned up and
4040
pizza cost £8 per 2 people?
@@ -45,7 +45,7 @@ could go into this calculation?
4545
## Storing text in variables
4646

4747
As well as numbers variables are able to store text, known in Python as
48-
strings.
48+
strings.
4949

5050
Now in the REPL type:
5151

@@ -79,9 +79,9 @@ not.
7979
Python is what's called a "typed language". This is to say that there are
8080
multiple *types* of objects that you work with in Python, and they don't all
8181
act the same way. The three types you've learnt so far are *integers* (`int`),
82-
*floats* (`float`), and *strings* (`str`). Integers are whole numbers, floats
83-
are numbers with a decimal point, and strings are any number of characters
84-
surrounded by either "" or ''. This is important to know because every Python
82+
*floats* (`float`), and *strings* (`str`). Integers are whole numbers, floats
83+
are numbers with a decimal point, and strings are any number of characters
84+
surrounded by either "" or ''. This is important to know because every Python
8585
programmer has tried to do this at least once in their career:
8686

8787
"7" + 8
@@ -119,9 +119,9 @@ of these for the final part of this tutorial.
119119
## Storing user input in variables
120120

121121
Now we are going to look at capturing user input using the python input
122-
command. Let's create a variable in which to store the user input.
122+
command. Let's create a variable in which to store the user input.
123123

124-
Now type this into your REPL:
124+
Now type this into your REPL:
125125

126126
>>> lucky_number = input("What is your lucky number? ")
127127

@@ -138,7 +138,7 @@ Now try:
138138
>>> my_name = input("What is your name? ")
139139
>>> greeting = "Hello " + my_name
140140

141-
Then type `greeting` into your REPL to receive your message.
141+
Then type `greeting` into your REPL to receive your message.
142142

143143
## Decision making using variables
144144

@@ -147,7 +147,8 @@ around with decision making and changing prints based on your answer. In Python
147147
(and many other languages), one of the most common ways in which this is done
148148
is using an `if` statement. For example:
149149

150-
>>> if number > 3:
150+
>>> number = 4
151+
... if number > 3:
151152
... print("Bigger than three")
152153
... elif number < 3:
153154
... print("Smaller than three")
@@ -170,7 +171,7 @@ Let's create a variable called `coffee` and put your coffee cup total into it:
170171
>>> coffee = input("How many cups of coffee have you consumed today? ")
171172

172173
Now we'll use some simple if/else logic to decide what to say about your
173-
drinking habits:
174+
drinking habits:
174175

175176
>>> if int(coffee) > 4:
176177
... print("You have a coffee problem")

0 commit comments

Comments
 (0)