Data types are the building blocks of any programming language. They define what kind of data can be stored and manipulated within a program. Understanding data types is crucial for writing efficient and effective code.

Common Data Types

Here are some of the most common data types:

  • Integer: Whole numbers, like 5, -3, or 42.
  • Float: Numbers with a decimal point, like 3.14 or -0.001.
  • String: Textual data, like "Hello, world!" or "The quick brown fox".
  • Boolean: True or false values.

Examples

Let's see how these data types work in practice:

  • Integer:

    age = 25
    print(age)
    
  • Float:

    pi = 3.14159
    print(pi)
    
  • String:

    name = "Alice"
    print("Hello, " + name + "!")
    
  • Boolean:

    is_valid = True
    print(is_valid)
    

Data Type Conversion

Sometimes, you might need to convert one data type to another. For example, converting a string to an integer:

age_str = "25"
age_int = int(age_str)
print(age_int)

Learn More

To dive deeper into data types, check out our Data Types Guide.

Data Types Illustration