Python data structure

beginning

The following code is completed in the interactive interface (you can also write the code into the script, you need to add print(...) to display):

The interactive command prompt of python is:

>>>

The content entered after this symbol will run in real time and display the results of the run.

For example, if we enter 2 it will produce the following changes:

>>> 2
2
>>> 

We enter 2, and python reads 2 as a number, and then returns the entered number, which is 2.

What if we enter a Formula?

>>> 1+2
3
>>> 

Python will calculate the corresponding value.

Python contains algorithms that can perform scientific calculations. For example, if you enter:

>>> 7+3*7/5+5/3+(11*9+2)/5
33.06666666666666
>>> 

Python will perform operations based on the priority of arithmetic symbols.

Python can also directly perform large number operations, you can calculate any number less than 1e10000:

Where ** means to calculate the power.

We can use the type() function to observe the data type:

2 is an integer.

There are six data types in Python: Numbers, strings, lists, tuples, sets, dictionaries. Let's explain each data type in next a few chapter.

  • Numbers, strings, lists, tuples do not use hash table indexes.

  • sets, dictionaries use hash table index.

When introducing the data structure, we will use whether to include a hash table to introduce separately.

  • Numbers, strings, tuples are immutable.

  • lists, sets, dictionaries are variable.

I will talk about the difference between Variable and Immutable in a later chapter.

Statistics

Start time of this page: December 18, 2021

Completion time of this page: December 18, 2021

Last updated