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 python comments and operators look like

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Python comments and operators are like, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

1. Multi-file project walkthrough

Create two python files under day02

Click on a file and right-click to run it. A file box will appear in the upper right corner.

Run the second file, and the steps are the same

Delete output box contents

two。 Comments (the interpreter will not interpret the content on the right side of #) 2.1 single-line comments (line comments)

# followed by a space, there will be no grammatical errors

# this is the first comment print ("hello world") # this is the second comment print ("cat")

In the comment on the right, there are two spaces between code and #

Print ("pig") # second single-line comment 2.2 Multiline comment (block comment) "" this is multiline comment "" 3. Arithmetic operator 3.1operator a = 21b = 10print (a + b) print (a-b) print (a * b) print (a / b) print (a% b) # remainder print (a * * b) # Power print (a / / b) # divisible

Extension: "string"

"-" * 10

3.2 priority

Multiply and divide first and then add and subtract

Sibling: from left to right

You can use () to adjust the calculation priority

Sort arithmetic operators from high to low precedence

Example:

C = 2d = 3e = 4print (dwindles c + d * e) print (dudes * (c + d) * e)

Output

After reading the above, have you mastered the methods of python annotations and operators? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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

Development

Wechat

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

12
Report