Data Types

Primitive Data Types

Explore the fundamental Python primitive data types such as integers, floats, strings, booleans, and NoneType. Understand their characteristics and how to use them effectively in coding through detailed explanations and examples.

Primitive data types

Primitive data types are fundamental data types in a programming language that represent simple values. For instance, numbers, strings, etc.

Integers

Integers (int): Whole numbers that don’t have decimal points or aren’t fractions.

course_rank = 1 print("Course rank:", course_rank)

Integer data type in Python

Floats

Floats (float): Numbers that have a decimal point or are in exponential form.

value_of_pi = 3.14 print("The value of pi is:", value_of_pi)

Float data type in Python

Strings

Strings (str): Sequences of characters. The characters can be letters, numbers, symbols, spaces, or other special characters.

our_message = "Welcome to How.Dev! Let's learn Python Data Variables!" print("Our Message:", our_message)

String data type in Python

Booleans

Booleans (bool): Logical operation keywords. A Boolean represents either True or False.

is_learning_python = True print("Python Status:", is_learning_python)

Boolean data type in Python

Note: A string can be defined used single (‘ ‘), double (” “), or triple quotation marks (“”” “””). However, double quotation marks are the generally accepted way. Triple quotation marks are usually used for multiline strings.

NoneType

NoneType (None): Represents the absence of a value or a null value.

none_variable = None print("None Variable:", none_variable)

NoneType data type in Python

On this page

    In This Module