![]() ![]() |
Conceptual Review (page 17 of 55) |
A few of the common data types are the following:
1. bool is a binary variable containing the value of True or False.
2. str is a string variable containing text values.
3. int is an integer variable containing whole numbers (positive, negative or 0). An int may not have a decimal component.
4. float is a digital representation of a real number. A float is a way of representing a number with a fractional component on a computer.
5. list is a mutable collection of objects defined using hard brackets [].
6. tuple is an immutable collection of objects defined using parentheses ().
7. dict is a container that stores data in key-value pairs defined using curly brackets {}. It’s similar to a real-world dictionary, where you look up a word (key) to get its definition (value).
We use the type() function to check the data type. many traceback errors are the result of not knowing the data type of a variable when performing a task. Therefore, we use the type() function frequently to help us debug our code.