Lesson 1 (Data Types)
In algebra, most variables store numbers. However, computers can store other types of data as variables, in addition to numbers. Specifically, we will be storing four types of data in variables: floats, integers (ints), strings, and Booleans. We can use the command type() to assess the data type of the input.
Floats and ints
Floats and ints are both numbers; floats contain decimal points whereas ints are whole numbers, positive or negative.
If we would like to store or print a word instead of a number, we can use the string data type. We use double- or single- quotation marks to denote strings.
Conversion between data types
It is possible to convert from one data type to another with the commands float(), int(), and str().
The last data type we will be using is called a Boolean, which can take one of two values: True and False.
Now it's your turn!
- Identify the data type of the following variables. Hint: check your guess with the command type()