1. Recalling yesterday courses and jobs
1 #1.使用while循环输入 1 2 3 4 5 6 8 9 10 2 3 ''' 4 count = 0 5 while count < 10: 6 count += 1 # count = count +1 7 if count == 7: 8 print(' ') 9 else: 10 print(count) 11 #第二方法 12 13 count = 0 14 while count < 10: 15 count += 1 # count = count +1 16 if count == 7: 17 continue 18 print(count) 19 20 ''' 21 #3, the output of all odd 1-100 22 is # Method a: 23 is # COUNT. 1 = 24 # the while COUNT <101: 25 # Print (COUNT) 26 is # COUNT + 2 = 27 # Method two: 28 # COUNT. 1 = 29 # the while COUNT <101: 30 # IF COUNT == 2%. 1: 31 is # Print (COUNT) 32 # COUNT +. 1 = 33 is 34 is # 5, find all numbers 1-2 + 3-4 + 5 ... 99 and 35 # SUM = 0 36 # COUNT. 1 = 37 [ # The while COUNT <100: 38 is # IF COUNT% 2 == 0: 39 # SUM = SUM - COUNT 40 # the else: 41 is # SUM = SUM + COUNT 42 is # COUNT +. 1 = 43 is # Print (SUM) 44 is 45 # . 6 , user login (three opportunities retry) 46 is # iNPUT heart account, password the while 47 48 I = 0 49 the while I <. 3 : 50 username = iNPUT ( ' enter account number: ' ) 51 is password = int (iNPUT ( 'Enter password: ' )) 52 is IF username == ' salted Brother ' and password == 123 : 53 is Print ( ' successful login ' ) 54 is the else : 55 Print ( ' Login failed login again ' ) 56 is I = +. 1
2, the output format
# Formatted output # % SD # name the INPUT = ( 'Please enter your name') # Age = the INPUT ( 'Please enter the age') # height = the INPUT ( 'Please enter the height') # msg = "My name is% s, year % s height% s "% (name, Age, height) # Print (msg) " "" name = the iNPUT ( 'Please enter your name:') Age = the iNPUT ( 'Please enter ages:') the Job = the iNPUT ( 'please work input: ') Hobbie = iNPUT (' your hobby: ') MSG =' '' S% ----------------------- ----------- info of the Name: S% Age:% D Job:% S Hobbie:% S ------------- End ----------------- '' '% ( name, name, int (Age), the Job, Hobbie) Print (msg) "" " name = INPUT ( " Please enter the name ') Age = the INPUT ( ' Please enter the age ' ) height = the INPUT ( ' Please enter the height ' ) msg = " My name is% s,% s this height is% s learning progress %% S 3 " % (name, Age, height ) Print (msg)
3, while else loop
count = 0 while count <= 5 : count += 1 if count == 3:break print("Loop",count) else: print("循环正常执行完啦") print("-----out of while loop ------")
4, initial encoding
1 New 2 opening 3 a . 4 home 5 see 6 see . 7 A the BC . 8 01000010 01000011 . 9 telegram transmission of the computer, are stored 01010101 10 . 11 first ' codebook ' ASCII covers case letters, special characters, numbers. 12 ASCII representation only 256 possible, too, 13 founded Unicode Unicode 14 16 represent a character does not work, 32 represent a character. 15 A 01000001010000010100000101000001 16 B 01000010010000100100001001000010 . 17 I 01000010010000100100001001000010 18Upgrading Unicode UTF-16. 8-UTF UTF-32 . 19 8 = 1 byte bytes 20 is UTF. 8- a 8-bit character to represent a minimum, an 8-bit byte English 21 European languages used to represent 16-bit words section 22 Chinese represented with three bytes 24 to 23 is UTF-16 character by 16 to represent a minimum 24 25 GBK China's own invention, two bytes to represent a 16-bit by Chinese. 26 is 27 1bit 8bit = 1bytes 28 1byte 1024byte = 1KB 29 1KB 1024KB = 1MB 30 1MB 1024MB = 1GB 31 is 1GB 1024GB = 1TB
5, the logic operation
1 #and or not 2 #优先级,()> not > and > or 3 # print(2 > 1 and 1 < 4) 4 # print(2 > 1 and 1 < 4 or 2 < 3 and 9 > 6 or 2 < 4 and 3 < 2) 5 # T or T or F 6 #T or F 7 # print(3>4 or 4<3 and 1==1) # F 8 # print(1 < 2 and 3 < 4 or 1>2) # T 9 # print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T 10 # print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F 11 # print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F 12 # Print (Not 2>. 3. 1 and <. 4. 4 or>. 5 and 2>. 9. 1 and> or. 8. 7 <. 6) F. # 13 is 14 # PS int ----> BOOL converted to the nonzero converted bool True 0 bool is False 15 # Print (bool (2)) 16 # Print (bool (-2)) . 17 # Print (bool (0)) 18 is # #bool ---> int . 19 # Print (int (True)) # . 1 20 is # Print (int (False)) # 0 21 is 22 is 23 is '' ' X or YX True, it returns X ' '' 24 # Print (. 1 or 2) #. 1 25 # Print (. 3 or 2) #. 3 26 is # Print (or 0 2) # 2 27 # print(0 or 100) # 100 28 29 30 # print(2 or 100 or 3 or 4) # 2 31 32 # print(0 or 4 and 3 or 2) 33 '''x and y x True,则返回y''' 34 # print(1 and 2) 35 # print(0 and 2) 36 print(2 or 1 < 3) 37 print(3 > 1 or 2 and 2)