Python Data Types
In this post
The built-in types you will use every day, and how Python decides which one you have.
The built-in types you will use every day, and how Python decides which one you have.
The everyday types
Numbers, text, booleans and None cover most of what a program holds. type() answers what you actually have, which is the fastest way to settle an argument with yourself.
print(type(3), type(3.0))
print(type("3"), type(True), type(None))
Output:
Converting between them
Conversions are explicit. Python will not quietly add a string to a number, which is the error most often met on day one.
total = int("12") + 3
print(total, str(total) + " items")
Output:
15 15 items
Next
Carry on to the next tutorial in the rail — it picks up where this one leaves off.
PythonData Types