Notes on Data Types in Python

In Python, there are three main data types, each corresponding to different scenarios: 1. Numeric types 2. Sequence types 3. Hash types. Within these three main data types, there are also many subcategories.

# First category: Numeric types
# Contains three subcategories: Integer type
# What is an integer? An int consists of digits from 0-9, all of which are called integers.
# Is there a concept of negative numbers? Yes.
b = 10000
print(b)
print(type(b))  # <class 'int'>

# Floating-point type: float is the decimal in everyday life. Any number with a decimal point is a floating-point number.

a = 1314.0
print(a)
print(type(a))  # <class 'float'>

# Boolean type: bool is used to determine truth values. One is called true, and the other is called false.
# The Boolean type is a keyword.
# True represents 1, and False represents 0. Note the capital letter.

a = True
b = False
print(a)
print(type(a))  # <class 'bool'>
print(b)

Leave a Comment