Lesson 3 of 34
Data Types: Numbers, Text and True/False
8 min 20 XP
Every value in Python has a type: whole numbers are int, decimals are float, text is str, and True/False is bool. type() tells you the type.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.Careful: "10" is text (a string), while 10 is a number. Adding two strings joins them. To calculate, convert them to numbers with int().
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.int("5") → 5, float("2.5") → 2.5, str(10) → "10". This is called type conversion.