What Is a Data Type?

A data type describes the kind of value stored in a variable.
It tells the computer:

  • how the value should be stored in memory
  • how the value should be interpreted
  • what operations can be performed on it

Without data types, a computer would not know how to treat values correctly.


Why Data Types Matter

Data types help programs:

  • behave predictably
  • avoid logical errors
  • use memory efficiently

For example, adding two numbers is different from combining two pieces of text.


Categories of Data Types

In most programming languages, data types are grouped into two main categories:

  1. Primitive data types the most basic and built-in data type in a programming language that is used to store a single simple value such as a number, character, or logical value.
  2. Composite (or complex) data types custom data types created by combining multiple primitive types into a single structure to represent more complex objects or collections.

Primitive Data Types

Primitive data types usually store a single value.

Integer (int)

Stores whole numbers, either positive or negative.

Examples:

10
-5
0
count = 10

Floating-Point Number (float)

Stores numbers with decimal points.

Examples:

3.14
0.5
price = 9.99

Character (char)

Stores a single character.

grade = 'A'

Some languages treat characters differently or do not have a separate char type.

String

Stores a sequence of characters (text).

message = "learning programming"

Strings are commonly used to represent names, messages, and text input.

Boolean

Stores logical values.

is_active = True
is_active = false

Boolean values are often used in conditions and decision-making.


Composite (Complex) Data Types

Composite data types are used to store multiple values in a single structure.

Array

An array is a data structure that stores multiple values under one variable name.
You can think of an array as a container that holds several items.

In some languages:

  • all elements in an array must have the same data type
  • in others, elements can be of different data types

Examples

Python (mixed data types allowed)

data = [1, "apple", 3.14, True]

C (single data type only)

int numbers[3] = {1, 2, 3};

Choosing the Right Data Type

Choosing the correct data type:

  • makes your program clearer
  • prevents unexpected behavior
  • improves performance

Always select the data type that best represents the value you want to store.


In Short

  • A data type defines what kind of value is stored
  • Data types control how values behave
  • They are divided into primitive and composite
  • Every variable has a data type, explicitly or implicitly

Built slowly, with curiosity and love. © 2026 Achly .

This site uses Just the Docs, a documentation theme for Jekyll.