Data is information stored by the computer. In Python, we have many different types of data: strings, integers, floating numbers, boolean, and some others (that we won’t cover in this course). You can check the type of data of an object by using type( ). ( Make sure to put the object between the parentheses!)
"I went to the store", "i", "12345", and "#^*&#)^&"-1, 0, 1, 2, 3, 100. They can’t have any decimals.1.2, 5.4, 2.6, 1.8
5.0 might look like an integer, but since there’s a decimal point, it’s a float, even if there’s nothing after the decimal pointTrue or False (We’ll go deeper into booleans later in the course, for now just know that they exist)<aside>
🚨 Case matters in Python! True and False are syntactically correct, while true and false are syntactically incorrect.
</aside>
Example code:
# *strings are a series of characters*
# they are in single or double quotes
print("Jane")
print('Doe')
# *integers are whole numbers (positive, negative, and 0)*
print(25)
# *floating point numbers (floats) are numbers with decimals)*
print(16.54)
*# booleans are either true or false*
print(True)
print(False)
View code on GitHub.
<aside> ⚖️ Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact [email protected] for inquiries.
</aside>