Get the App
SLTechnology News&Howtos  ›  Database  › 

Initial python database

Shulou Source: shulou.com Published: 2022-06-01 17:07:48 09月30日 Update

1. Number

2 is an example of an integer.

Long integers are just larger integers.

3.23 and 52.3E-4 are examples of floating-point numbers. The E mark represents the power of 10. In this case, 52.3E-4 means 52.3 * 10-4.

(- 5cm 4J) and (2.3-4.6J) are examples of complex numbers, in which-5Power4 is a real number and j is an imaginary number. What is a complex number in mathematics?

Int (Integer)

On a 32-bit machine, the number of digits of an integer is 32 bits, and the range of values is-2147483648, or-2147483647.

On a 64-bit system, the number of bits of an integer is 64 bits, and the range of values is-2 bits 63-1, that is,-92233720368547758089223372036854775807

Long (long Integer)

Unlike the C language, Python's long integers do not specify a bit width, that is, Python does not limit the size of long integer values, but in fact, due to the limited machine memory, the long integer values we use can not be infinite.

Note that since Python2.2, if an integer is overflowed, Python automatically converts the integer data to a long integer, so not adding the letter L after the long integer data now does not cause serious consequences.

Float (floating point)

Literacy http://www.cnblogs.com/alex3714/articles/5895848.html first

Floating-point numbers are used to deal with real numbers, that is, numbers with decimals. Similar to the double type in C language, it occupies 8 bytes (64 bits), of which 52 bits represent the bottom, 11 bits represent the index, and the remaining one bit represents the symbol.

Complex (plural)

The complex number consists of the real number part and the imaginary number part, the general form is x+yj, where x is the real part of the complex number, y is the imaginary part of the complex number, where x and y are real numbers.

Note: there is a small number pool in Python:-5 ~ 257

2. Boolean value

True or false

1 or 0

3. String

"hello world"

Evil string concatenation:

The string in python is embodied as an array of characters in C language. Every time you create a string, you need to open up a continuous empty space in memory, and once you need to modify the string, you need to open up space again, and every time the evil + sign appears, it will open up a new space.

String formatted output

1234name = "alex" print "I am% s"% name # output: i am alex

PS: the string is% s; integer% d; floating point% f

Common string functions:

Remove whitespace

Split up

Length

Indexes

Slice

4. List

Create a list:

123name_list = ['alex',' seven', 'eric'] or name_list = list ([' alex', 'seven',' eric'])

Basic operations:

Indexes

Slice

Additional

Delete

Length

Slice

Cycle

Include

5. Tuple (immutable list)

Create a tuple:

123ages = (11, 22, 33, 44, 55) or ages = tuple ((11, 22, 33, 44, 55))

6. Dictionary (unordered)

Create a dictionary:

123person = {"name": "mr.wu", 'age': 18} or person = dict ({"name": "mr.wu",' age': 18})

Common actions:

Indexes

Add

Delete

Key, value, key-value pair

Cycle

Length

Tags: Integers characters strings plural real parts examples numbers indexes imaginary numbers language length data evil digits memory dictionaries commonly used numerical values machines Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Redmi vpn Huawei