Luozm +

Python Summary-1 general usage

Common functions in Python

原创文章,转载请注明:转自Luozm's Blog

The Python summary series include common operations, functions and libraries related to Algorithm Design and Data Science.

1. Basic Syntax

1.1 Indentation

if statement:
    #code block, code without indentation will not be part of

while condition:
    #code block

2. Operations

2.1 Arithmetic operations

Operator Name Description
a + b Addition Sum of a & b
a - b Subtraction Difference of a & b
a * b Multiplication Product of a & b
a / b True Division Quotient of a & b
a // b Floor Division Quotient of a & b, removing fractional parts
a % b Modulus Reminder after division of a by b
a ** b Exponentiation a raised to the power of b
-a Negation The negative of a

2.2 Comparison operations (return True or False)

Operator Description
a == b a equal to b
a != b a not equal to b
a < b a less than b
a > b a greater than b
a <= b a less than or equal to b
a >= b a greater than or equal to b

3. Lists

© Luozm . All rights reserved. | Top

Life

Theory

Develop