python learning the first day

Variables and type:

Integer: Python can handle any size integer (Python 2.x, there are two types int and long integer, but this distinction is of little significance for Python, only integer int in Python 3.x in this one kind of), but also support binary (eg 0b100, converted to decimal is 4), octal (eg 0o100, converted to decimal is 64), decimal ( 100) and hexadecimal ( 0x100converted to decimal 256) representation.

Floating-point type: decimal floating point is, is called float, because when expressed in terms of scientific notation, decimal point position a floating-point number is variable, floating point math in addition to the wording (such as 123.456addition) also supports scientific notation (such as 1.23456e2).

String: string is a single or double quotes any text, such as 'hello'and "hello", as well as the string representation of the original string, byte string representation, Unicode string representation, and can be written in a plurality of in rows (beginning with three single quotes, or three double quotes, three single or double quotation marks the end of three).

Boolean: Boolean only True, Falsetwo kinds of values, either True, or is False, in Python, can be directly used True, Falsea Boolean value indicating (note the case), can also be calculated by Boolean operators (e.g., 3 < 5generates a Boolean value True, and 2 == 1It will produce a Boolean value False).

Complex type: the form 3+5j, represents a complex mathematical with the same, the only difference is the imaginary part ireplaced j.

Variable name:

For each variable we need to give it a name, just as each of us has his own famous name the same. In Python, variable naming need to follow these rules must comply with rigid and non-rigid rules is strongly recommended to follow.

    • Hard and fast rule:
      • Variable names consist of letters (generalized Unicode characters, not including special characters), numbers, and the underscore, numbers can not begin.
      • Case sensitive (uppercase aand lowercase Aare two different variables).
      • Do not tell keywords (words that have special meaning, will be mentioned later) and system reserved words (such as the name of the function, module, etc.) conflict.

Exercise:

Guess you like

Origin www.cnblogs.com/zabandon/p/11272327.html