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 = 1print("Course rank:", course_rank)
Floats
Floats (float): Numbers that have a decimal point or are in exponential form.
value_of_pi = 3.14print("The value of pi is:", value_of_pi)
Strings
Strings (str): Sequences of characters. The characters can be letters, numbers, symbols, spaces, or other special characters.
our_message = "Welcome to Educative! Let's learn Python Data Variables!"print("Our Message:", our_message)
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.
Booleans
Booleans (bool): Logical operation keywords. A Boolean represents either True
or False
.
is_learning_python = Trueprint("Python Status:", is_learning_python)
NoneType
NoneType (None): Represents the absence of a value or a null value.
none_variable = Noneprint("None Variable:", none_variable)