You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that you know about variables, you want to use them to associate them with some data. Here, we will be using variables to store information related to a vacation that we would like to go on.
7
+
8
+
Just as before, we ask you to run the code and ensure that it matches what is commented out.
9
+
10
+
### Learning Objectives
11
+
12
+
* Practice variable assignment in Python
13
+
* Practice variable reassignment in Python
14
+
15
+
### Assigning variables
16
+
17
+
Assign a variable of `travel_month` equal to the string "January", as that is the month you would like to travel.
18
+
19
+
20
+
```python
21
+
travel_month =None
22
+
```
23
+
24
+
> We start by setting the variable equal to the data type None. As you know, `None` represents the absence of a value. And now you can take care of assigning the variable to something other than `None`.
25
+
26
+
27
+
```python
28
+
travel_month # "January"
29
+
```
30
+
31
+
Now let's assign a variable equal to the number of weeks that you would like to travel, 3.
32
+
33
+
34
+
```python
35
+
number_of_weeks =None
36
+
```
37
+
38
+
39
+
```python
40
+
number_of_weeks # 3
41
+
```
42
+
43
+
Now, you just learned that you can travel for a longer period of time. So reassign the `number_of_weeks` variable equal to `5`.
44
+
45
+
46
+
```python
47
+
number_of_weeks # 5
48
+
```
49
+
50
+
Now that's more like it.
51
+
52
+
### Summary
53
+
54
+
Great! In this lab, you were able to get a sense how to store information in variables through assignment and reassignment.
0 commit comments