Python3 data type, python3 Data Type
1. Basic Data Types
Numeric type
Integer int
Float
Boolean bool: True = 1, False = 0
Complex Type complex
Arithmetic Operator +-* // % **
Assignment operator + =-= * =/= // = % = ** =
Built-in functions max () and min () are used to calculate the maximum and minimum values.
Import decimal
2. Sequence type
'''
# String str, list, And tuple
# Sequence creation and type conversion
# Create a string: single or double quotation marks, three quotation marks, but must appear in pairs
# Create a list: [] brackets separated by commas
# Creating tuples: () parentheses, or comma-separated items
'''
Ss = 'Hello world'
List1 = [1, 3, 5, 7, 9]
Tp = 1, 2, 3, 'A'
3. type conversion
# Length of built-in function len ()
# Sequence type features: Each element in a sequence has a character number, also known as an index.
# Each element has its own index value, with both forward and reverse indexes,
# Forward index indicates that the index value of an element starts from 0 by default from left to right.
# General sequence operations:
# Using indexes for values and slices
# Addition: only the same type can be added +
# Repetition: sequence * number of repetitions
# Check the Member: in, not in to determine whether the element is in the sequence.
4. List methods and attributes
'''
L. append (obj) adds a new object to the end of the list.
L. clear () clears the entire list.
L. copy () copy list, which is similar to the replication method of L.
L. count (obj) counts the number of times an element appears in the list.
L. extend (seq) expands the original list with the new list.
L. index (obj) finds the index location of the first matching item of a value from the list.
L. insert (index, obj) inserts an element. You can specify the position.
L. pop (obj = list [-1]) to exit the stack. You can specify the position.
L. remove (obj) removes the first specified element from the left.
L. Elements in the reverse list of reverse.
L. sort () sorts the original list.
'''
Ls = [3, 1, 6, 7, 5, 4]
Ls. append (12)
Ls. reverse ()
Print (ls)
5. variable objects and immutable objects
# Variable objects: List, dictionary, and set
# Immutable object: String, tuples, and numeric type