Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use operator in Python

Shulou Source: shulou.com Published: 2022-06-02 22:40:28 09月27日 Update

This article will explain in detail how to use operators in Python. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

1. The meaning of the operator

+ plus sign

-minus sign

/ (slash) division

* (asterisk) multiplication

% (percent sign) modular division

Greater than sign

= greater than or equal to sign

2. Operation

The operation of operators in Python basic learning is completely the difficulty of calculation at the primary level. Yes, you are not mistaken, the addition, subtraction, multiplication and division here completely follow the basic algorithms, such as starting from left to right, multiplication and division first, and parentheses first. Here is a code example:

Print "I will now count my chickens:"

Print "Hens", 25 + 30 / 6

Print "Roosters", 100-25 * 3% 4

Print "Now I will count the eggs:"

Print 3 + 2 + 1-5 + 4% 2-1 / 4 + 6

Print "Is it true that 3 + 2

< 5 - 7?" print 3 + 2 < 5 - 7 print "What is 3 + 2?", 3 + 2 print "What is 5 - 7?", 5 - 7 print "Oh, that's why it's False." print "How about some more." print "Is it greater?", 5 >

-2

Print "Is it greater or equal?", 5 > =-2

Print "Is it less or equal?", 5

Tags: Operations operators China Games articles multiplication and division basis that is parentheses more good practical addition subtraction multiplication and division multiplication code content minus sign plus sign meaning primary schoo Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Linux Huawei Docker