Variables Lab
Introduction
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.
Just as before, we ask you to run the code and ensure that it matches what is commented out.
Learning Objectives
- Practice variable assignment in Python
- Practice variable reassignment in Python
Assigning variables
Assign a variable of travel_month
equal to the string "January", as that is the month you would like to travel.
travel_month = None
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 thanNone
.
travel_month # "January"
Now let's assign a variable equal to the number of weeks that you would like to travel, 3.
number_of_weeks = None
number_of_weeks # 3
Now, you just learned that you can travel for a longer period of time. So reassign the number_of_weeks
variable equal to 5
.
number_of_weeks # 5
Now that's more like it.
Summary
Great! In this lab, you were able to get a sense how to store information in variables through assignment and reassignment.