Description of indentation in basic python tutorials and indentation in basic python tutorials
Python operators are similar to those in other languages.
(Currently, we only know the basic usage of these operators, so that we can expand the following content. Advanced applications are not introduced at the moment)
Mathematical operations
Copy codeThe Code is as follows:
>>> Print 1 + 9 # Addition
>>> Print 1.3-4 # Subtraction
>>> Print 3*5 # Multiplication
>>> Print 4.5/1.5 # Division
>>> Print 3 ** 2 # multiplication party
>>> Print 10% 3 # Calculate the remainder
Judgment
Returns True/False if it is True or False.
Copy codeThe Code is as follows:
>>> Print 5 = 6 #=, equal
>>> Print 8.0! = 8.0 #! =, Not equal
>>> Print 3 <3, 3 <= 3 # <, less than; <=, less than or equal
>>> Print 4> 5, 4> = 0 #>, greater than; >=, greater than or equal
>>> Print 5 in [1, 3, 5] #5 is an element of list [1, 3, 5 ].
(There are also is, is not, and so on, not in-depth)
Logical operation
Operation between True and False
Copy codeThe Code is as follows:
>>> Print True and True, True and False # and, "and", both are True.
>>> Print True or False # or, "or" operation. If one of them is True, it is True.
>>> Print not True # not, non operation, Inverse Operation
It can be used with the previous part to do some exercises, such:
Copy codeThe Code is as follows:
>>> Print 5 = 6 or 3> = 3
Summary
Mathematics +,-, *,/, **, %
Judgment = ,! =,>,> =, <, <=, In
Logic and, or, not
Who can introduce python indentation in detail?
In fact, it is very simple to select two spaces, four spaces, and one tab. You just need to select one of the three, but you can only select one. It is recommended to use some development ides, which will automatically indent you many times. For example, WingIDE is very useful.
Python indent
Try not to input multiple rows in shell, which may cause alignment problems. You can try to write these statements into a py file and then run them. The following is an example.
Def main (): try: print "A" character T: print "C" if _ name _ = '_ main _': main ()