First, the use of Pycharm
1. Create a project
2. Python adjust font size with Ctrl + mouse wheel scroll up and down
3, Python new program auto-completion coding and environment
4. Set a breakpoint (click the left mouse button after the line number in front of the code)
5. Debugging breakpoints
Two, in, not in
s = ' old boy alexwusir ' print (' old boy ' in s) print (' Old boy ' in S ') print (' Old man ' in ') print (' Old man ' in s) ' comment = input (' Please enter your comment: ') if ' Cang jing empty ' in Comment: print (' re-enter ' The sensitive word you entered ')
In a string, a substring containing the definitions contained in a female string must be contiguous to true, discontinuous is a false,in representation of inclusion, and not in represents non-containment.
Third, while Else
Count = 1while True: print (count) if count = = 3:break count + = 1else: print (' Loop normal complete ')
Count = 1= True while flag: Print(count) if count = =3 := False + = 1else: Print( ' The loop is complete normally . ')
If the loop is interrupted by a break, the program does not go else
Four, formatted output
STR string d digit digits
The first type:
Name = input (' Please enter your name: ') Age = input (' Please enter your age: ') hobby = input (' Please enter your hobby: ') msg = ' My name is%s, this year%d, hobby%s '% (Name,int (ages), hobby) Print (msg)
The second Kind
DIC = {' name ': ' Old boy ', ' age ': Wuyi, ' hobby ': ' no matter '}msg = ' I'm called% (name) s, year% (age) d, hobby% (hobby) s '% Dicprint (msg)
< Span style= "COLOR: #000080" > Pure display% in formatted output is solved by percent.
/span>
Name = input (' Enter your Name: ') Age = input (' Please enter your Age: ') msg = ' My name is%s, this year is%d, learning progress is 1%% '% (Name,int (ages)) print (msg)
V. Operators
And Or not
The first kind: both before and after are comparison operations.
Priority level: () >Not >>Or the same priority, calculated from left to right.
Print1 >2and3 <4and3 >2Or2 <3)
Print2 >1and3 <4or 4 > 5 and 2 < 1)
print (1 > Span style= "COLOR: #0000ff" >2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8)
The second type: both front and back are numeric operations.
X or y if x True, return x, otherwise return y
Print1Or3)
Print1or 3)
print (2 or 3)
print (0 or 3)
print (-1 or 3)
print (1 and 2)
print (0 and 2)
the third type: blending.
print (1 > 2 or 3 and 4)
print (2 or 2 > 3 and 4"
print (0 or 2 > 3 and 4)
Data type conversions:
int---> BOOL non 0 that true,0 is false
BOOL---> int True 1 False 0
Print (int (True))
Print (int (False))
Print (bool (100))
Print (bool (0))
Print (2)
If the or is preceded by a non-0 number, only the previous result is taken, and vice versa.
Six, the Code
Initial Password Book:
ASIIC contains numbers, English, special characters. Eight guests
01000001 01000010 01000011 A B C
8 bit = 1 byte represents a character.
Unicode, the language of all countries is included in this cipher.
Initial: 16-bit, two-byte, representing one character.
a:00010000 00010010
Medium: 00010010 00010010
Upgrade: 32-bit, four-byte, representing one character.
a:00010000 00010010 00010000 00010010
Medium: 00010010 00010010 00010010 00010010
Waste of resources.
Upgrade: Utf-8. Use a minimum of 8 bits (one byte) to represent one character.
English: a:00010000 represents a character with 8 bits.
Europe: 00010000 00010000 16 bits Two bytes represent one character.
Asia: 00010000 00010000 00010000 24 bits, three bytes represents one character.
Utf-16
GBK: GB.
Contains only: English Chinese.
English: a:00010000 8 bits, one byte representing one character.
Chinese: 00010000 00010000 16 bits, two bytes represents one character.
gb2312 .....
Knowledge Review
Determine the true,false of the following logical statements.
1) 1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
2) not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
2. Find the values of the following logical statements.
1), 8 or 3 and 4 or 2 and 0 or 9 and 7
2), 0 or 2 and 3 and 4 or 6 and 0 or 3
3. What are the following results?
1), 6 or 2 > 1
2), 3 or 2 > 1
3), 0 or 5 < 4
4), 5 < 4 or 3
5), 2 > 1 or 6
6), 3 and 2 > 1
7), 0 and 3 > 1
8), 2 > 1 and 3
9), 3 > 1 and 0
10), 3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
4. Brief description of variable naming conventions
5. Name = input (">>>") what is the data type of the name variable?
6. What is the basic structure of the IF condition statement?
7. While loop statement basic structure?
8. Write code: Calculate 1-2 + 3 ... + 99 The sum of all the numbers except 88?
9. Login (three chance of error) and display the number of remaining errors (hint: Format the string) for each loss
10. Describe the ASCII, Unicode, utf-8 encoding relationships?
11. Describe the relationship between bits and bytes?
12. "The Boy"? UTF-8 code accounted for?? A byte? Make? GBK is the number of bytes encoded?
13. Create Fun template program requirements: Waiting for the user to lose? Name, place, hobby, according to the name and hobby of the family into? Any reality such as: love and amiable xxx, favorite in XXX?? Xxx
14. Wait for the user to lose content, to detect the loss of the contents of the content contains sensitive characters? If there is a sensitive character hint that "there are sensitive characters, please re-lose", and allow the user to re-lose and print. Sensitive characters: "? Matte", "Hammer"
15. Single comment and multi-comment?
16. Describe the difference between Python3 and Python2 you know?
17. Look at the code writing results:
A = 1>2 or 4<7 and 8 = = 8
Print (a)
18.continue and break difference?
Day3 Dictation Code:
The conversion relationship between BIT,BYTES,KB,MB,GB,TB.
UNICODE,UTF-8,GBK, each encoded in English, Chinese, respectively, in a few bytes.
True
False
7
3
6
3
0
3
True
True
0
3
0
4
Cannot start with special symbols, _ or letters, concise and meaningful, avoid keywords
String str
If condition:
Results
Else
Results
While condition:
Results
Count = 0
sum = 0
While Count < 99:
Count + = 1
if count== 88:
continue
Elif count% 2 = = 1:
Sum + = Count
Else:
Sum-= Count
Print (sum)
Count = 3
While count > 0:
Username = input (' Enter user name: ')
Password = input (' Enter password: ')
Count-= 1
if username== ' HJ ' and password== ' 123 ':
Print (' login successful ')
Break
else:
Pass
print (' user name or password error, remaining input count%s ' % count ')
Name = input (' Please enter name: ')
site = input (' Please enter location: ')
Hobby = input (' Please enter hobby: ')
msg = ' beloved '%s, favorite%s '% dry '% (name,site,hobby)
Print (msg)
Flag = True
while flag:
Keyword = ' little pink Big hammer '
search = input (' Please enter search content: ')
if search in keyword:
Print (' Your input contains sensitive words, please re-enter ')
Else:
Print (' successful input ')
Flag = False
Python full stack development, Day2