Skip to content

Commit 39c63b6

Browse files
committed
made some typo fixes and reworded some phrases
1 parent a444ea5 commit 39c63b6

File tree

2 files changed

+119
-71
lines changed

2 files changed

+119
-71
lines changed

README.md

+75-19
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
### Declaring and Assigning Variables
2222

23-
So far we have only worked with data -- strings, numbers, and booleans. In this lesson, we'll learn how to use variables to assign names to this data. For example, this is a string from our Working with **Data Types Lab**.
23+
So far we have worked with data -- strings, numbers, and booleans. In this lesson, we'll learn how to use variables to assign names to this data. For example, this is a string from our Working with **Data Types Lab**.
2424

2525

2626
```python
@@ -34,20 +34,20 @@ So far we have only worked with data -- strings, numbers, and booleans. In this
3434

3535

3636

37-
Now months later, if we see that string in some code, we may be confused as to what it's about. And when we add more data, this only becomes more difficult. Think of the what we saw in our **Data Types Lab**: `"[email protected]"`, `"Ceo"`, `"7285553334"`, `"vandelay.com"`. There's a lot to keep track of.
37+
Now months later, if we see that string in some code, we may be confused as to what it is, and with even more data, this only becomes more difficult. Think of what we saw in our **Data Types Lab**: `"[email protected]"`, `"Ceo"`, `"7285553334"`, `"vandelay.com"`. There's a lot to keep track of.
3838

39-
So let's use a variables to indicate what each of these strings mean.
39+
So, let's use variables to indicate what each of these strings mean.
4040

4141

4242
```python
4343
4444
```
4545

46-
> For this, and all of the subsequent code in gray boxes, you should press shift + enter to ensure that the code executes. If you do not do so with the line above for example, then `email` when we reference `email` in the lines that follow, Jupyter will throw an error indicating that the variable is undefined. So it is not enough to just type the correct code, we need to run shift + enter on our gray boxes to run this code.
46+
> **Note:** For this, and all of the subsequent code in gray boxes, you should press shift + enter to ensure that the code executes. If you do not do so with the line above for example, then when we reference `email` in the lines that follow, Jupyter will throw an error indicating that the variable is undefined. So, it is not enough to just type the correct code, we need to run shift + enter on our gray boxes to run this code.
4747
48-
In programming terms, we say that just "declared a variable `email` and assigned it to the string `"[email protected]"`". And to do so, we'll follow the procedure above:
48+
In programming terms, we say that we just declared a variable, `email`, and assigned it to the string, `"[email protected]"`. To do so, we'll follow the procedure below:
4949

50-
`variable = data`
50+
variable = data
5151

5252
Now that we have assigned a variable `email` to a string, we just type the word `email` to see the string again.
5353

@@ -56,9 +56,9 @@ Now that we have assigned a variable `email` to a string, we just type the word
5656
email
5757
```
5858

59-
> Press shift + enter on the gray box above to see what `email` equals.
59+
> *remember to press shift + enter on the gray box above to see the value of our variable, *`email`*.*
6060
61-
Ok, let's do this with the website too.
61+
Now let's try this with the website:
6262

6363

6464
```python
@@ -98,34 +98,90 @@ So this is assigning and reading a variable. And when we want to see some infor
9898

9999
```python
100100
email
101+
```
102+
103+
### Declaring variables without assignment
104+
105+
We have seen that we can have data without assigning it to variables.
106+
107+
108+
```python
109+
"Unassigned data"
110+
```
111+
112+
113+
114+
115+
'Unassigned data'
116+
117+
118+
119+
Sometimes we wish to declare a variable without assigning it to data. In Python, that's a little tricky to do. As we just saw with `name`, declaring variables without assignment throws an error. Thankfully, Python has a special type for us that represents nothing at all.
120+
121+
122+
```python
123+
None
124+
```
125+
126+
127+
```python
128+
type(None)
129+
```
130+
131+
132+
133+
134+
NoneType
135+
101136

137+
138+
None is a data type in Python that represents nothing. So, if we do not know the type of a variable and want to have the data to the variable be assigned later, we can assign that variable to `None`.
139+
140+
141+
```python
142+
address = None
102143
```
103144

145+
Notice that `address` is now assigned, but it is assigned to `None`.
146+
147+
148+
```python
149+
address
150+
```
151+
152+
**Note:** *when variables are assigned to `None`, pressing shift + enter on the cell block will not output anything.*
153+
104154
### Reassigning variables
105155

106-
Now that we have this data, you can imagine using it for some instructions. For example, say you want to write some yourself a memo on who and how to reach out to someone you just met. Here's the message:
156+
Now that we have this data, we can imagine using it for some kind of instruction. For example, say we want to write ourself a memo on how to reach out to someone we just met. Here's the message:
107157

108158

109159
```python
110-
"Send an email to Art Vandalay at '[email protected]' to tell say how nice it was meeting yesterday."
160+
"Send an email to Art Vandalay at '[email protected]' to say how nice it was meeting yesterday."
111161
```
112162

113163
If we construct this message with variables, we can write the following:
114164

115165

166+
```python
167+
name = "Art Vandalay"
168+
169+
```
170+
171+
116172
```python
117173
"Send an email to " + name + " at " + email + " to say how nice it was meeting yesterday."
118174
```
119175

120-
Now you meet someone else, "Liz Kaplan" with the email of "[email protected]" and want to write a memo with the same instructions, but the only thing that varies are the name and email. So then this is easy enough. First we change set the variables `name` and `email` equal to different data.
176+
Now you meet someone else, "Liz Kaplan" with the email of "[email protected]" and want to write a memo with the same instructions, but the only thing that varies are the name and email. This should be easy enough given the way we set up our memo above. First we need to change the variables, `name` and `email`, by setting them to our new data.
121177

122178

123179
```python
124180
name = 'Liz Kaplan'
125181
126182
```
127183

128-
So as you can see, we reassign our variable by just setting `variable = 'new data'`. And our variable is then updated.
184+
So as you can see, we reassign our variables by just setting `variable = 'new data'`. Presto, our variable is then updated.
129185

130186

131187
```python
@@ -137,11 +193,11 @@ name # 'Liz Kaplan'
137193
138194
```
139195

140-
And now, if we copy and run our previous code again, it is automatically updated.
196+
Now, if we copy and re-run our previous code, we will see it is automatically updated.
141197

142198

143199
```python
144-
"Send an email to " + name + " at " + email + " to tell him how nice it was meeting him yesterday."
200+
"Send an email to " + name + " at " + email + " to say how nice it was meeting yesterday."
145201
```
146202

147203
So in the line above, we are getting to some of the real power of programming. By choosing the correct variable name, we can begin to change the values of `name` or `email` and operate on their underlying values in the same ways.
@@ -165,7 +221,7 @@ name.upper()
165221
name.title()
166222
```
167223

168-
So just like we directly call methods on a string, we can also call methods on a variable that points to a string. And, if try to call a method on something that you think is a string, but really is a number, you will see an error.
224+
Just like how we are able to directly call methods on a string, we can also call methods on a variable that points to a string. And, if we try to call a method on something that we think is a string, but really is a number, we will see an error.
169225

170226

171227
```python
@@ -177,14 +233,14 @@ name = 42
177233
name.upper()
178234
```
179235

180-
Just like we would recieve that error from calling on number `42` more easily. So now, that we are working with variables, you may run into errors where you think a variable is one thing, but really it is something else. But it's no big deal. We just see what the variable is.
236+
We receive the same error from calling `upper` directly on the number `42` as we do when we call `upper` on a variable that points to the number `42`. So, now that we are working with variables, we may run into errors where we thought a variable is one thing, but it is actually something else. Don't worry, this is no big deal. We can just check to see what the variable is.
181237

182238

183239
```python
184240
name
185241
```
186242

187-
And make the change.
243+
Once we have see what the variable is, we can make our change.
188244

189245

190246
```python
@@ -194,6 +250,6 @@ name
194250

195251
### Summary
196252

197-
In this lesson, we got a taste for what makes computer programs so powerful. By using variables, we can write programs that know how to combine data. This can save us time by avoiding boring, repetitive tasks. We declare and assign a variable with the pattern of `variable = data`. And reassign a variable with the same pattern. To refernece a variable, we simply type the variable's name.
253+
In this lesson, we got a taste for what makes computer programs so powerful. By using variables, we can write programs that know how to combine data. This can save us time by avoiding boring, repetitive tasks. We declare and assign a variable with the pattern of `variable = data`, and reassign a variable with the same pattern. To reference a variable, we simply type the variable's name.
198254

199-
We also saw that one of the things to pay attention to when working with variables is that they are sometimes different from what we expect. So we just type the name of the variable, to see what it really is and make the change.
255+
We also saw that one of the things to pay attention to when working with variables is that they are sometimes different from what we expect. So we just type the name of the variable, to see what it really is and make any necessary changes.

0 commit comments

Comments
 (0)