1, input and output input-output
input () function when the input string is input.
Input format: variable = inut ( "prompt character")
eval () function can be converted into a digital string. Thus, eval () function is a very common function
print output format control: print ( "enter here described {: .2f}". format (variable))
When the output string without formatting control, print ( "Output Format error")
comma print function becomes the result output space
2, python import standard library
Python import using the import function in three ways to Example turtle
import turtle from turtle import setup or from turtle import * import (alias t is to call the library) turtle as t
In general, to make use of a third
3, to determine whether the elements in a list
Finally, in possible whether a character in an array inside
4 comments
Single-line comments: beginning with #
Multi-line comments: In '' 'three single quotes i.e., the beginning and end
5, the data type
String type single and double quotes is the same
List: an ordered sequence of zero or more data consisting of a list of the [], a comma-separated elements
6, the string
Index: A [m]
Slice: A [1: 3] means that the first, second character fetched character, but does not include the third character
7, for loop
Format: for variable in range (parameters)
loop statement
Count each cycle is variable
range () function generating cyclic count sequence:
The first format is: range (N), to generate a sequence of integers 0 to N-1, a total of N
The second format is: range (M, N), to generate a sequence of integers from N-1 to M, a total of NM
8, the basic data types
-
Integer type: can be positive or negative, there is no limit of the range. pow (x, y): y-th power of x
-
Float type: Inter uncertain mantissa floating-point operations, so that when the floating-point calculation, the round function is often used.
-
round function Usage: round (x, d), the x-rounded, d is the decimal digits taken
-
Scientific notation: 4.3e-3 represents 0.0043,9.6E5 represented 960000.0
-
Complex type: z = a + bj, where, a is the real part, b is the imaginary part. z.real obtaining the real part, z.imag imaginary part is obtained
9, the value operator that
-
x / y represents the x divided by y, and the significance of mathematics, like, generally produce float
-
// y x denotes integer division, takes only the integer quotient of x and y
-
% Remainder, modulo operation
-
x ** y x to the power y denote
10, numerical computation function
-
ABS (x) absolute value of x
-
divmod (x, y) while the output quotient and remainder
-
pow (x, y [, z]) power I, represents (x ** y)% z, z may be omitted, omit equivalent to 1 modulo
-
round (x [, d]) rounded, d decimal digits are reserved, the default value is 0
-
max (x1, x2, ...., xn) selecting the maximum value, the size is not limited to n
-
min (x1, x2, ..., xn) for the minimum, not the size of n
11, casts function
-
int (x) x fractional part is discarded and the integer becomes a
-
a float (x) increases fractional part of the floating point number x
-
Complex (x) changes in the imaginary part of the complex number x into
12, python logic operation