Python (1), python (

Source: Internet
Author: User

Python (1), python (

Abs (x)

Returns the absolute value of a number. For example, abs (-10) returns 10.

Ceil (x)

Returns the upper integer of a number. For example, math. ceil (4.1) returns 5.

Cmp (x, y)

If x <y returns-1, if x = y returns 0, if x> y returns 1

Exp (x)

Returns the x power of e (ex). For example, math. exp (1) returns 2.718281828459045

Fabs (x)

Returns the absolute value of a number. For example, math. fabs (-10) returns 10.0

Floor (x)

Returns the rounded down integer of a number. For example, math. floor (4.9) returns 4.

Log (x)

For example, math. log (math. e) returns 1.0, math. log (2.0) returns

Log10 (x)

Returns the logarithm of x on the base of 10. For example, math. log10 (100) returns 2.0.

Max (x1, x2 ,...)

Returns the maximum value of a given parameter, which can be a sequence.

Min (x1, x2 ,...)

Returns the minimum value of a given parameter, which can be a sequence.

Modf (x)

Returns the integer and decimal parts of x. The numerical symbols of the two parts are the same as those of x, and the integer part is expressed as a floating point.

Pow (x, y)

The value after the x ** y operation.

Round (x [, n])

Returns the rounding value of floating point x. If n is given, it indicates the number of digits rounded to the decimal point.

Sqrt (x)

Returns the square root of number x. The number can be a negative number and the return type is a real number. For example, math. sqrt (4) returns 2 + 0j.

Choice (seq)

Randomly select an element from the element of the sequence, such as random. choice (range (10), from 0 to 9

Select an integer at random.

Randrange ([start,] stop [, step])

Obtains a random number from a set that increments by the specified base number within the specified range. The default value of the base number is 1.

Random ()

The next real number is randomly generated within the range of [0, 1.

Seed ([x])

Change the seed of the random number generator. If you do not understand the principle, you do not need to set the seed,

Python will help you select seed.

Shuffle (lst)

Random sorting of all elements in a sequence

Uniform (x, y)

The next real number is randomly generated, which is within the range of [x, y.

 

 

Acos (x)

Returns the arc cosine radians of x.

Asin (x)

Returns the arc sine radians of x.

 

Atan (x)

Returns the arc tangent radians of x.

 

Atan2 (y, x)

Returns the arc tangent of the given X and Y coordinate values.

 

Cos (x)

Returns the cosine of the radians of x.

 

Hypot (x, y)

Returns the euclidean norm sqrt (x * x + y * y ).

 

Sin (x)

Returns the sine of x radians.

 

Tan (x)

Returns the tangent of x radians.

 

Degrees (x)

Converts radians to degrees. For example, if degrees (math. pi/2), 90.0 is returned.

 

Radians (x)

Converts degrees to radians.

 

 

Pi

Mathematical constant pi (circumference rate, usually expressed by π)

E

Mathematical constants e, e are natural constants (natural constants ).

 

+

String connection

A + B output

Result:

HelloPyth

On

*

Repeated output string

A * 2 output

Result: HelloHello

[]

Obtain characters in a string using Indexes

A [1] Output

ResultE

[:]

Truncates a part of a string.

A [] Output

ResultEll

In

Member operator-returns True if the string contains a given character

H inInput

Output result 1

Not in

Member operator-returns True if the string does not contain the given characters

M not in

AOutput result

1

R/R

Original string-original string: All strings are directly used literally,

No escape special or printable characters.

Except that the letter "r" (case-sensitive) is added before the first quotation mark of the string,

It has almost the same syntax as a normal string.

Print R' \ N' 

Output

\ N andPrint

R' \ N'

Output \ n

%

Format String

 

 

Mode

Description

R

Open the file in read-only mode. The file pointer will be placed at the beginning of the file. This is the default mode.

Rb

Open a file in binary format for read-only. The file pointer will be placed at the beginning of the file. This is the default mode.

R +

Open a file for reading and writing. The file pointer will be placed at the beginning of the file.

Rb +

Open a file in binary format for reading and writing. The file pointer will be placed at the beginning of the file.

W

Open a file for writing only. If the file already exists, overwrite it. If the file does not exist, create a new file.

Wb

Open a file in binary format for writing only. If the file already exists, overwrite it. If the file does not exist, create a new file.

W +

Open a file for reading and writing. If the file already exists, overwrite it. If the file does not exist, create a new file.

Wb +

Open a file in binary format for reading and writing. If the file already exists, overwrite it. If the file does not exist, create a new file.

A

Open a file for append. If the file already exists, the file pointer is placed at the end of the file. That is to say, the new content will be written to the existing content. If the file does not exist, create a new file for writing.

AB

Open a file in binary format for append. If the file already exists, the file pointer is placed at the end of the file. That is to say, the new content will be written to the existing content. If the file does not exist, create a new file for writing.

A +

Open a file for reading and writing. If the file already exists, the file pointer is placed at the end of the file. When the file is opened, the append mode is used. If the file does not exist, create a new file for reading and writing.

AB +

Open a file in binary format for append. If the file already exists, the file pointer is placed at the end of the file. If the file does not exist, create a new file for reading and writing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.