Skip to content

Commit 3195877

Browse files
committed
python tutorial conditions for final task
1 parent 7c0c078 commit 3195877

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

python/lesson2/tutorial.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Python tutorial 2
55

66
In this tutorial we are going to look at variables, user input and decision making.
77

8-
##Creating a variable
8+
### Creating a variable
99

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

@@ -17,7 +17,7 @@ In this example you have now stored the value `2015` into the variable `year`. S
1717

1818
How about saving your age into a variable or your lucky number? Have a play around with storing numbers into variables. Let us know if you think of something more exciting to store in variables than the year.
1919

20-
##Storing numbers in variables
20+
### Storing numbers in variables
2121

2222
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.
2323

@@ -33,7 +33,7 @@ How much money would a sponsor at codebar spend on pizza if they had 60 students
3333

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

36-
##Storing text in variables
36+
### Storing text in variables
3737

3838
As well as numbers varaiables are able to store text, known in Python as string.
3939

@@ -54,13 +54,13 @@ Now store some strings in variables that contain apostrophes and some that do no
5454

5555
What happens when you store a number in a variable wrapped in quotes?
5656

57-
##Storing user input in variables
57+
### Storing user input in variables
5858

5959
Now we are going to look at capturing user input using the python input command.
6060

6161
Let's create a variable in which to store the user input. Now type this into your REPL:
6262

63-
question = input("What is your lucky number?")
63+
lucky_number = input("What is your lucky number?")
6464

6565
Type back your answer after it asks you.
6666

@@ -74,14 +74,27 @@ When you give the REPL your repsonse make sure you wrap it in quotes as this is
7474

7575
Now try:
7676

77-
name = input("What is your name?")
78-
greeting = "Hello " + name
77+
my_name = input("What is your name?")
78+
greeting = "Hello " + my_name
7979

80-
Then type `message` into your REPL to receive your message.
81-
80+
Then type `greeting` into your REPL to receive your message.
8281

83-
### Further Reading
8482

83+
### Decision making using variables
84+
85+
Now that we know how to use variables and know how to store data, let's play round with decision making and changing input based on your answer.
86+
87+
In this final exercise we are going to ask you the number of coffees you have drank todaya and then change the statament back at you depending on your answer.
88+
89+
Let's create a variable called:
8590

86-
ADD NOTE ABOUT NAMING VARIABLE!
91+
coffee = input("How many cups of coffee have you consumed today?")
92+
93+
if coffee >= 4:
94+
print "You have a coffee problem"
95+
else:
96+
print "You do not have a coffee problem"
97+
98+
99+
### Further Reading
87100

0 commit comments

Comments
 (0)