days2.python basis and work

Program
terminal; the input file address directly in the command window,
Python Software = python interpreter;
Environment Variables: configuration environment variable, simply enter the file name, you can open the file

File form
#! / usr / bin / env python in linux system, the file must be added to this code to identify their interpreter is Python.
# - - Coding: utf8 - -: do not need python3, the python2 in for the use of Chinese, must plus.

A variable
-generation refers to a change in the value of the
naming rules: 1 letter underlined numbers (numbers not beginning)
2. key ()
3. python and built things repeat (function)
two conditional statements.
1.python indented to be consistent
if 12:
Print ( 'good')
the else:
Print ( 'bad')
almost continuousl nested statement
if 1
1:
if 12:
Print ( "good")
the else:
Print ( "bad")
the else:
Print ( "very bad")
3.pass; nothing to write
# Pass
IF 1
1:
Pass
the else:
Print ( 'bad')
. Third data type
1. (1) string (marks)
a = "Alex"
a = "Alex"
a = "" "Alex" ""
(2) Digital
a . 1 =
B 10 =
2. operation
string operators: + connection duplicate
numbers: + plus subtraction - multiplication
addition / // List number%

Four loop
1. The figures obtained with whlie statement. 5. 4. 3 2. 6. 1. 9 10. 8
A. 1 =
the while A <. 11:
IF A. 7:
a = a # +. 1 without this statement, the result becomes 123,456, when performing a
7:00, not self plus one, will result in an infinite loop.
the else:
Print (A)
A = A +. 1
the else:
Print ( "the END")
2. 1-100 and seeking 5050 =
A. 1 =
B 0 =
the while A <101:
B = A + B
A + A. 1 =
the else:
Print (B)
Print ( "the END")
3. seeking 1-100 odd (even)
a. 1 =
the while a <101:
IF a == 2%. 1:
Print (a)
a = a +. 1
the else:
. 1 = A + A
the else:
Print ( "the END")

Guess you like

Origin blog.csdn.net/qq_33410381/article/details/92383320