1, the definition of variables (assignment)
Variable name = value
Not need to specify the type of variable is a variable defined in the Python, the program, when executed, depending on the value Python interpreter = right, derive the exact type of data.
2, the data type
Digital type:
int integer
float float
bool Boolean false: 0 true: a non-zero number
complex complex scientific notation
Non-numeric type:
string string must be enclosed in quotation marks
list list
tuble tuple
dict dictionary
ipython common function type (variable names) ---- View variable type
The TIP: In python 2.X, the integer value stored depending on the length of the further divided into:
int (integer)
long (long integer) 3872222222222222222222222222222222222222222222 L
When the arithmetic calculation may be performed, arithmetic operation between the direct numeric variables: true = 1, false = 0.
Stitching string variables, + stitching: "Zhang" + "three"
* The string number n: repeatedly output n times to change the string, can not be performed between addition operations other variable strings and numbers
4, a few simple functions
Content within parentheses print output print () to the console
Variable formatted output: while the output text, together with a digital output, is called formatting operator%
% S: string
% D: decimal number with a sign, integers% 06d represents a display output bits, with zeros insufficient
After two display float,% 02f decimal point:% f.
%%: Output%
Syntax:
print ( "format string" variable 1%)
print ( "format string"% (variable 1, variable 2, ...))
type () variable of type View
input (str) Gets keyboard typing str message. input ( "Please enter your bank password!"), to acquire the content is of type string.
int () converts an integer variable type; int ( "11")
float () converts the variable to a float; float ( "11.5")
3, variable naming
debug:
F8 single step.
Shift + F9 to open a debug.
Re-run debug
Release code to the next breakpoint F9.
No longer perform debug mode
Set a breakpoint
Cancel Breakpoint