Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the precedence of the python operator

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the priority of python operator". In daily operation, I believe many people have doubts about what the priority of python operator is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "what is the priority of python operator?" Next, please follow the editor to study!

I. the role of supplement /

/ / used for rounding, which refers to the integer part of the result after division. Warm tip: there is also a function int () that gets the integer part, which returns an integer part after converting the floating point number.

% is used to take the remainder, which refers to the remainder of the result after division.

Used for division, the result is an actual division result, and if there is a decimal, a decimal is returned.

Operator precedence

General operator precedence: from left to right.

Priority from high to low:

1. Parentheses ()

2. Power operator * *

3. Minus sign-

4. Multiply * divide / divide / / take the remainder%

5. Add + subtract-

After knowing the priority of the operator, we can make our calculation and judgment more accurate in the process of complex condition judgment and mathematical calculation.

III. Summary and emphasis

1. Master the difference between / and / and%.

2. master the priority of each operator.

Operator example:

(10 Universe 3% 2) = 1

(10 Universe 3% 2) * 2

(- 1 inch 3-(10 Universe 3% 2) * 2) = 0

2-inch 2 + (- 1-3-(10-pound 3%) * 2) = 4-0-4

At this point, the study of "what is the priority of the python operator" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report