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

藏色散人
Release: 2019-07-01 09:46:44
Original
18750 people have browsed it

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
Copy after login

Subtraction:

Enter the following code:

>>>1-2
>>>1.0-2
Copy after login

Multiplication:

Enter the following code:

>>>2*4
>>>2.0*4
Copy after login

Division:

Enter the following code:

>>>2/4
>>>2.0/4
>>>2//4
>>>2.0//4
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!