Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Is 0x 18 a legal python integer constant?
Is 0x 18 a legal python integer constant?
0x 18 is a legal python integer constant.

Python numeric data types are used to store numeric values.

Changing the numeric type is not allowed, which means that if the value of the numeric data type is changed, the memory space will be reallocated.

The following example creates a Number object when assigning variables:

IntOne= 1

IntTwo=2

You can also use the del statement to delete references to some digital objects.

Delton

Delintenius

Of course, it is also allowed to delete multiple:

The second paragraph

Python supports three different numeric types:

Integer(Int)- called integer, which is a positive integer or a negative integer without decimal point. Python3 integers have no size limit. That is, there is no restriction on the size of int types like java.

Float)-Float consists of integer part and decimal part, and can also be expressed by scientific notation (2.5e2 = 2.5 x 102 = 250).

Complex number ((complex number))-Complex number consists of real part and imaginary part, and can be represented by a+bj or complex number (a, b). The real part A and imaginary part B of a complex number are both floating-point types. It is also possible to express imaginary numbers with expressions.

Python number type conversion

Sometimes, we need to convert built-in data types. For data type conversion, you only need to use data type as the function name.

Int(x) converts x into an integer.

Float(x) converts x into a floating point number.

Complex(x) converts x into a complex number, with the real part being x and the imaginary part being 0.

Complex(x, y) converts x and y into complex numbers, where the real part is x, the imaginary part is y, and x and y are numerical expressions.

Python can use the * * operation to perform exponentiation:

Variables must be "defined" (that is, given a value) before being used, otherwise an error will occur:

When different types of numbers are mixed, integers will be converted into floating-point numbers (of course, referring to different numbers, and if they are not numbers, errors will occur)

Common functions:

Absolute value of abs(x) x

Ceil () returns an integer of numbers, such as math.ceil(4. 1) returns 5.

Use (x & gty)-(x

Exp(x) returns e to the power of x (ex), for example, math.exp( 1) returns 2.718281828459045.

Fabs(x) returns the absolute value of a number, such as math.fabs(- 10) returns 10.0.

Floor(x) returns a rounded integer of a number, for example, math.floor(4.9) returns 4.

Log(x) such as math.log(math.e) returns 1.0, and math.log (100, 10) returns 2.0.

Log 10(x) Returns the logarithm of x based on 10. For example, math.log 10( 100) returns 2.0.

Max(x 1, x2,,) returns the maximum value of a given parameter, which can be a sequence.

Min(x 1, x2) gets the minimum value of a given parameter, which can be a sequence.

Mdf(x) returns an integer part and a decimal part of x, the numerical sign of which is the same as that of x, and the integer part is expressed as a floating-point type.

The value after pow(x, y) x**y operation.

Round(x, n) returns the rounded value of floating-point number X. If n is given, it means the number of digits rounded to the decimal point.

Sqrt(x) returns the square root of the number x.

Random number function

Random numbers can be used in mathematics, games, security and other fields, and are often embedded in algorithms to improve the efficiency of algorithms and the security of programs.

Choice(seq) randomly selects an element from the sequence, such as random.choice(range( 10)), and randomly selects an integer from 0 to 9.

Randrange(start, stop, step) obtains a random number from a set that increases by a specified radix within a specified range, and the default value of the radix is 1.

Random () randomly generates the next real number with the range of [0, 1].

Seed(x) Change the seed of the random number generator. If you don't know the principle, you don't have to set it up specially. Python will help you choose a seed.

Shuffle(seq) randomly arranges all the elements in the sequence.

Un format(x, y) randomly generates the next real number in the range of [x, y].

Mathematical constant:

namely