@@ -10,7 +10,7 @@ making.
10
10
11
11
Python allows us to store data in something called variables so that we are
12
12
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.
14
14
15
15
Now in the REPL type:
16
16
@@ -34,7 +34,7 @@ Now in the REPL type the following:
34
34
>>> costs = 200
35
35
>>> profit = revenue - costs
36
36
37
- Now type ` profit ` to see the results of this calculation.
37
+ Now type ` profit ` to see the results of this calculation.
38
38
39
39
Now work out the cost of running a codebar workshop if 60 people turned up and
40
40
pizza cost £8 per 2 people?
@@ -45,7 +45,7 @@ could go into this calculation?
45
45
## Storing text in variables
46
46
47
47
As well as numbers variables are able to store text, known in Python as
48
- strings.
48
+ strings.
49
49
50
50
Now in the REPL type:
51
51
79
79
Python is what's called a "typed language". This is to say that there are
80
80
multiple * types* of objects that you work with in Python, and they don't all
81
81
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
85
85
programmer has tried to do this at least once in their career:
86
86
87
87
"7" + 8
@@ -119,9 +119,9 @@ of these for the final part of this tutorial.
119
119
## Storing user input in variables
120
120
121
121
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.
123
123
124
- Now type this into your REPL:
124
+ Now type this into your REPL:
125
125
126
126
>>> lucky_number = input("What is your lucky number? ")
127
127
@@ -138,7 +138,7 @@ Now try:
138
138
>>> my_name = input("What is your name? ")
139
139
>>> greeting = "Hello " + my_name
140
140
141
- Then type ` greeting ` into your REPL to receive your message.
141
+ Then type ` greeting ` into your REPL to receive your message.
142
142
143
143
## Decision making using variables
144
144
@@ -147,7 +147,8 @@ around with decision making and changing prints based on your answer. In Python
147
147
(and many other languages), one of the most common ways in which this is done
148
148
is using an ` if ` statement. For example:
149
149
150
- >>> if number > 3:
150
+ >>> number = 4
151
+ ... if number > 3:
151
152
... print("Bigger than three")
152
153
... elif number < 3:
153
154
... print("Smaller than three")
@@ -170,7 +171,7 @@ Let's create a variable called `coffee` and put your coffee cup total into it:
170
171
>>> coffee = input("How many cups of coffee have you consumed today? ")
171
172
172
173
Now we'll use some simple if/else logic to decide what to say about your
173
- drinking habits:
174
+ drinking habits:
174
175
175
176
>>> if int(coffee) > 4:
176
177
... print("You have a coffee problem")
0 commit comments