Variables and numeric types

Variables and Data Types

Digital number: int integer, float float

string String: single and double quotation marks, three marks (multiple lines)

bool Boolean: 1 (True) or 0 (False) can be treated as integer

list file: index starts from 0 [1,2,3, "hi", [4,5,6]] Review: list [0] = 100

tuple Ganso: immutable (1,2,3,4,5)

dict dictionary: random index value + value { "a": 100, "b": 150}

Data type conversion

float()10→10.0

str () operation can not be performed

int () directly to rounding

BOOL () converts a value Boolean: 0,0.0, None, '', [], {} indicates false

Recognized variable

Variable naming rules

1 to alphanumeric underscores beginning with the letter underlined

2, and does not coincide with the name commonly used functions of

3, no spaces

Assignment of variables

1, the single variable assignment: a = 1

2, multi-variable assignment: a = b = 1 c, d, f = 2,3,4

3, dynamic variables: overwrite the previous assignment later

Operators

Arithmetic operators

Modulo: remainder%

power:**

Divisible: //

Comparison operators (judgment statement)

<= >= == !=

Logical operators (and, or, not)

Member operator (in, not in) lists, dictionaries, tuples, strings

Note

Generally appear in scripted programming, code description, the backup role.

“”“

Note Note

”“” #

Guess you like

Origin www.cnblogs.com/evan-wang/p/12128632.html