• Digital type
a = 100` ` `# int
b = 3.14` ` `# float
c = True` ` `# bool type
d = 1 + 2i  ```# complex
Copy the code
  • string

Strings in Python are enclosed in single or double quotation marks, requiring a uniform format throughout the program.

cat = "Tom"                 
mouse = 'Jerry'
Copy the code
  • The list of

A list is an ordered collection of data types whose elements can be of any data type. The list data is written in the middle of [] to separate each element. Element values in a list can be evaluated using element subscripts.

myList = [1."hello Python"[1.2.3]]         
print(myList[1])
Copy the code
  • tuples

A tuple is an ordered set of data types whose elements can be of any data type. The tuple data is written in the middle of () to split each element. Element values in tuples can be evaluated using element subscripts.

myTuple = (1."Hello Python"[1.2], (1.2))    
print(myTuple[2])
Copy the code
  • A collection of

A collection is an unordered collection data type with no duplicate elements. It can only store elements of the Number, String, and Tuple types. Set data is written in the middle of {} to separate each element. If there are duplicate elements in the definition collection, it removes them.

mySet = {1.2."set", (1.2)}               
mySet = {1.1.2."set", (1.2)} ` ` `# remove a 1
Copy the code
  • The dictionary

A dictionary is a mapped set data type whose element is an unordered combination of keys and values. The elements inside are delimited by {} between the elements used, split, keys and values used: split. Dictionary values use Key to obtain Value.

student = {"name": "Lily"."age": 18."sex": "Female"}     
print(student["name"]) ` ` `# get Value ' 'where key is name
Copy the code