Python Beginner Learning Basics Operator--arithmetic operator

Source: Internet
Author: User
Tags arithmetic operators

Arithmetic operators

Before the article in the introduction of variable types, in fact already used a lot of arithmetic characters, such as + 、-、 *,/,//, * *, and so on, in addition, there is a symbol is not mentioned before, is%, used to return the division of the remainder of the operation symbol.

Assuming that the variables x and y,x are 10,y to 3,x%y, the result is 1.

There are precedence in the operators, as in mathematics, so there are some need for precedence in writing, such as: 3 * (4 + 5).

Python supports the addition of different numeric types, which use a number type cast to solve the problem of inconsistent numeric types, that is, it converts one operand to another data type with the same operand. However, the operation of this cast is not arbitrary, there are rules to follow: integer to floating point, non-complex to plural. Can be understood as simple to turn into complex, because the floating-point number can represent the same as an integer value (0 after the decimal point), the imaginary part of the complex is 0 can be used to represent the non-plural.

Now let's look at a small example of 24, mainly to familiarize yourself with the concept of arithmetic operations in Python, and perhaps you have more and better ways to calculate it.

Learn more, just in the code bud Net Http://www.mayacoder.com/lesson/index

Python Beginner Learning Basics Operator--arithmetic operator

Related Article

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.