Data types are the building blocks of programming. They define the kind of data that can be stored and manipulated within a program. Understanding different data types is crucial for writing efficient and effective code.
Common Data Types
Here are some of the most common data types used in programming:
- Integer (int): Represents whole numbers, both positive and negative.
- Floating-point (float): Represents numbers with decimal points.
- Boolean (bool): Represents true or false values.
- String (str): Represents text data.
- List: A collection of items that can be of different types.
- Tuple: An ordered collection of items that cannot be modified.
- Dictionary: A collection of key-value pairs.
Example
Here's an example of how you can declare variables of different data types in Python:
age = 25 # Integer
height = 5.9 # Floating-point
is_student = True # Boolean
name = "Alice" # String
grades = [90, 85, 88] # List
info = (name, age) # Tuple
student_details = {"name": "Alice", "age": 25} # Dictionary
For more information on data types in Python, you can visit the Python Data Types page.
Images
Here are some images related to data types: