@@ -14,7 +14,7 @@ it a name then set its value.
14
14
15
15
Now in the REPL type:
16
16
17
- >>> year = 2016
17
+ >>> year = 2016
18
18
19
19
In this example you have now stored the value ` 2016 ` into the variable ` year ` .
20
20
See what happens next when you type `year' into the REPL. Does it show it back
@@ -30,9 +30,9 @@ variables with the maths operations we learnt in the previous tutorial.
30
30
31
31
Now in the REPL type the following:
32
32
33
- >>> revenue = 1000
34
- >>> costs = 200
35
- >>> profit = revenue - costs
33
+ >>> revenue = 1000
34
+ >>> costs = 200
35
+ >>> profit = revenue - costs
36
36
37
37
Now type ` profit ` to see the results of this calculation.
38
38
@@ -49,22 +49,22 @@ strings.
49
49
50
50
Now in the REPL type:
51
51
52
- >>> name = 'codebar'
53
- >>> url = "codebar.io"
52
+ >>> name = 'codebar'
53
+ >>> url = "codebar.io"
54
54
55
55
Now type ` name ` and ` url ` to see these strings shown back to you. As you can
56
56
see Python allows both single and double quotes to denote a string variable.
57
57
Double quotes are required if there is going to be an apostrophe in the string.
58
58
59
59
For example:
60
60
61
- message = "I'm a string"
61
+ message = "I'm a string"
62
62
63
63
Sometimes you will need to use an apostrophe within a single quote, on
64
64
occasions like this it is recommended to use "string escaping". This would look
65
65
like:
66
66
67
- message ='I\'m a string'
67
+ message ='I\'m a string'
68
68
69
69
Try storing a string within a variable without quotes, see what happens?
70
70
Numbers do not require quotation marks, whereas they are mandatory for storing
@@ -122,20 +122,20 @@ command. Let's create a variable in which to store the user input.
122
122
123
123
Now type this into your REPL:
124
124
125
- >>> lucky_number = input("What is your lucky number? ")
125
+ >>> lucky_number = input("What is your lucky number? ")
126
126
127
127
Type back your answer after it asks you.
128
128
129
129
Now in the REPL type:
130
130
131
- >>> food = input("What is your favourite food? ")
131
+ >>> food = input("What is your favourite food? ")
132
132
133
133
Now we are going to put your response into another variable.
134
134
135
135
Now try:
136
136
137
- >>> my_name = input("What is your name? ")
138
- >>> greeting = "Hello " + my_name
137
+ >>> my_name = input("What is your name? ")
138
+ >>> greeting = "Hello " + my_name
139
139
140
140
Then type ` greeting ` into your REPL to receive your message.
141
141
0 commit comments