Python----------Digital Foundation

Source: Internet
Author: User
Tags integer division mathematical functions

Integral type operation, subtraction:

2 + 242*362-11
12/5
2
#假如想要使返回的结果为浮点数, they can be written in the form of floating-point numbers.
12.0/5.0
2.4

Power Index:

3**29

Residual:

22%52

Use type() functions to view variable types:

A = 1TPE (a) int
Floating point number (float):
A = 1.34type (a) float
Interactive calculation:
1 + 2-(3 * 4/6) * * 5 + 7% 5-27# in Python, precedence is the order of arithmetic, such as "first multiplication plus minus" and "first parentheses" are two priority rules, the priority from high to low ranked as follows: 1. () Brackets 2. * * Power exponential operation 3. *///% multiplication, except, integer division, remainder operation 4. ' +-' plus minus

Integer division, which returns the maximum integer value that is smaller than the result:

12.3//5.2   2.0
Simple Mathematical functions:

Absolute:

  

ABS (-251.451) 251.451

Rounding:

Round (22.3) 22

Maximum minimum value:

Print min (2, 3, 4, 5) 2print Max (2, 4, 3) 4
Type conversions:

Floating-point integer, which retains only the integral part:

print int (12.324) 12print int (-3.32)-3
In situ calculation:
b = 2.5b + = 2print b4.5b *=29
Boolean type:

A Boolean can be considered a special two-value variable with a value True of False :

Q = Truetype (q) BOOLQ = 1 > 2print qfalse

Python----------Digital Foundation

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.