1. The first day of learning python

A programming language
       Expression can be recognized by a computer programming language, i.e., language communication medium, and a computer programming language to communicate with a programmer medium.
       Programming that is based on the needs of programmers to write down their thoughts flow in accordance with the syntax of a programming language style, the result is the output file that contains a bunch of characters.
Second, variable
Variable names naming convention:
1. To begin with a letter or an underscore English name, beginning a1 # English alphabet; 3_a # underscore;
2. Do not start with a number
3 can not be named with the keyword
4. Do not use the Chinese name, not the name is too long
Strong push python named: age_of_xue
Three features define variables:
the above mentioned id # is used to indicate the value of the variable in memory only a memory address
type type # variable value
value value # variables
 
Third, the constant (refer to the same amount)
The constant is variable in nature, will not have any mechanism in python restrictions you can not modify a constant, but artificial restrictions python programmer own
naming conventions: variable names all uppercase
 
Fourth, the user interacts with the program
Input: 
python3:
the INPUT ()
python2:
Output:
Print ()
Note: to use a single line with three multi-line quotes #
 
Fifth, the basic data types
    1. Digital Type:
        Integer: int
        Float: float
    2. String type
        role: name, sex, nationality, address and other descriptive information
        Definition: single quotation marks \ double quotes \ three marks, a string of characters
            name = 'tank'
 
The priority control operations:
            1, according to the index value (Forward + Reverse take take): can only take
            2, sections (care regardless of the end, step)
            3, the length len
            . 4, the members in operation in and Not
            . 5, shift In addition to the blank Strip
            . 6, segmentation Split
            . 7, loop
Need to know:
            . 1, Strip, the lstrip, The rstrip
            2, Lower, Upper
            . 3, startsWith, endsWith
            . 4, the format of the three kinds of games are played
            . 5, Split, rsplit
            . 6, the Join
            . 7, Replace
            . 8, isdigit
 
 
after class homework 
 name = " aleX"
1, both sides of the removed name spaces corresponding to the variable value, and outputs the processing result
name = " aleX"
print(name,name.strip())

 2, it is determined whether the value of "al" variable name corresponding to the beginning, and outputs the result

name = " aleX"
print(name.startswith('al'))

 3, corresponding to the variable name is determined whether the value of an "X" at the end, and outputs the result

name = " aleX"
print(name.endswith('X'))

 4, the value corresponding to the variable name in the "l" is replaced with "p", and outputs the result

name = " aleX"
print(name.replace('l','p'))

5, the name of the corresponding variable value in accordance with "l" division, and outputs the result

name = " aleX"
print(name.split('l'))

 6, the corresponding value becomes the variable name in uppercase, and outputs the result

name = " aleX"
print(name.upper())

7, the name variable value corresponding to lower case, and the output

name = " aleX"
print(name.lower())

8, please outputs of the two character values ​​corresponding to the variable name?

name = " aleX"
print(name[1])

9, please output the first three characters of the name value of the corresponding variable? 

name = " aleX"
print(name[:3])

10, please output the value of two variables corresponding character name?

name = " aleX"
print(name[-2:])

11, please output value corresponding to the variable name in the index where the "e" position?

name = " aleX"
loc = []
for i,j in enumerate(name):
    if j=='e':
        loc.append(i)
print(loc)

12, to obtain sequences, removing the last character. Such as: oldboy then get oldbo

name = " aleX"
print(name[:-1])

Guess you like

Origin www.cnblogs.com/xunxunmimi2012/p/11086978.html