Skip to content

Commit f682f48

Browse files
committed
Merge pull request #193 from KimberleyCook/python-tutorial2
Python tutorial2
2 parents ef96984 + 99deb85 commit f682f48

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

python/lesson2/tutorial.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: page
3-
title: Python tutorial 2
3+
title: Playing with variables
44
---
55

66
In this tutorial we are going to look at variables, user input and decision making.
@@ -19,7 +19,7 @@ How about saving your age into a variable or your lucky number? Have a play arou
1919

2020
### Storing numbers in variables
2121

22-
Now that you are familair with the use of variables, we are able to combine variables with the maths operations we learnt in the previous tutorial.
22+
Now that you are familiar with the use of variables, we are able to combine variables with the maths operations we learnt in the previous tutorial.
2323

2424
Now in the REPL type the following:
2525

@@ -31,28 +31,28 @@ Now type `profit` to see the results of this calculation.
3131

3232
Now work out how much money a sponsor at codebar would spend on pizza if they had 60 students turn up?
3333

34-
Along with pizza, students and cost, what oher variables can you think of that could go into this calculation?
34+
Along with pizza, students and cost, what other variables can you think of that could go into this calculation?
3535

3636
### Storing text in variables
3737

38-
As well as numbers varaiables are able to store text, known in Python as strings.
38+
As well as numbers variables are able to store text, known in Python as strings.
3939

40-
Now in the REPl type:
40+
Now in the REPL type:
4141

4242
name = 'codebar'
4343
url = "codebar.io"
4444

45-
Now type `name' and `url` to see these strings shown back to you. As you can see Python allows both single and double quotes to denote a string variable. Double quotes are required if there is going to be an apostrophe in the string.
45+
Now type `name` and `url` to see these strings shown back to you. As you can see Python allows both single and double quotes to denote a string variable. Double quotes are required if there is going to be an apostrophe in the string.
4646

47-
For exmaple:
47+
For example:
4848

4949
message = "I'm a string"
5050

5151
Sometimes you will need to use an apostrophe within a single quote, on occasions like this it is recommended to use string escaping. This would look like:
5252

5353
message ='I\'m a string'
5454

55-
Try storing a string within a varable without quotes, see what happens? Numbers do not require quotation marks, whereas they are mandatory for storing strings.
55+
Try storing a string within a variable without quotes, see what happens? Numbers do not require quotation marks, whereas they are mandatory for storing strings.
5656

5757
Now store some strings in variables that contain apostrophes and some that do not.
5858

@@ -85,18 +85,18 @@ Then type `greeting` into your REPL to receive your message.
8585

8686
### Decision making using variables
8787

88-
Now that we know how to use variables and know how to store data, let's play around with decision making and changing prints based on your answer. In Python (and many other languages), one of the most commons ways in which this is done is using an if statement. For example:
88+
Now that we know how to use variables and know how to store data, let's play around with decision making and changing prints based on your answer. In Python (and many other languages), one of the most common ways in which this is done is using an if statement. For example:
8989

9090
if number > 3:
9191
print "Bigger than three"
9292
elif number < 3:
9393
print "Smaller than three"
9494

95-
Here we can see that if a number we have passed into this decision making code is bigger than three, we will recieve a messag telling us so, and the same relevant message if the number is smaller than three.
95+
Here we can see that if a number we have passed into this decision making code is bigger than three, we will receive a message telling us so, and the same relevant message if the number is smaller than three.
9696

9797
Also, now that we are getting more in depth with Python, we should say that Python is very particular about tabbing. Tabbing is the indents created when writing code. With Python, if any lines are not indented correctly the code will not run. If you are running into bugs, this is a good place to start.
9898

99-
In this final exercise we are going to ask you the number of coffees you have drank today and then change the statament returned to you, depending on your answer.
99+
In this final exercise we are going to ask you the number of coffees you have drank today and then change the statement returned to you, depending on your answer.
100100

101101
Let's create a variable called:
102102

@@ -107,6 +107,3 @@ Let's create a variable called:
107107
elif:
108108
print "You do not have a coffee problem"
109109

110-
111-
### Further Reading
112-

0 commit comments

Comments
 (0)