Home  >  Article  >  Backend Development  >  How to calculate addition, subtraction, multiplication and division in python

How to calculate addition, subtraction, multiplication and division in python

藏色散人
藏色散人Original
2019-07-01 09:46:4418753browse

How to calculate addition, subtraction, multiplication and division in python

Python is a high-level scripting language that combines interpretation, compilation, interactivity and object-oriented.

Note: The version used is Python3.5.2. (Because there is a big gap between the Python2 series and the Python3 series, special reminder)

Addition:

Enter the following code:

>>>1+1
>>>1.0+1

Subtraction:

Enter the following code:

>>>1-2
>>>1.0-2

Multiplication:

Enter the following code:

>>>2*4
>>>2.0*4

Division:

Enter the following code:

>>>2/4
>>>2.0/4
>>>2//4
>>>2.0//4

Note:

Operator: Add - Add two objects

Operator -: Subtraction - Get a negative number or one number minus another number

Operator*: Multiply - Multiply two numbers or return a string that is repeated several times

Operator/: Division - x divided by y

Operator//: Divide by integer - Return the integer part of the quotient (rounded down)

Related recommendations: "Python Tutorial

The above is the detailed content of How to calculate addition, subtraction, multiplication and division in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn