Summary
1. Determine if something is in something, in or not, and the result is a Boolean value (False or True)
Name = "Electromagnetic radiation"
v = "Inside" in name
Print (v)
2. Operators
+ - * / ** % //
The percent is the remainder, example 9%2=1, and/or the quotient, such as 9//2=4
3. The difference between break and continue
i = 0 while I < := i + 1 print(i) continue# orbreak print('test')Print ('end')
Continue continues to loop the condition in the while and does not perform the following content
Break above and below the content are not executed, jump out of the loop directly
4. While and if can be used as conditional judgment and else, but while can loop if but does not have this function.
i = 0 while I <: print(i) = i + 1else: Print ('else')print('end ')
5. Note that the print order is different and the output is different
i =0 whileI < 10: ifi = = 7: I= i + 1Continue Else: Print(i) I= i + 1#No output 7-----------------------------------------------------------------------------I=0 whileI < 10: ifi = = 7: I= i + 1Continue # Break Else: I= i + 1Print. IOPrint('End')#No output 8
--------------------------------------------------------------------------------------
Job: User Login (three chance retry)
i =0 whileI < 3: User_input= Input ("Please enter user name:") User_pwd= Input ("Please enter your password:") ifUser_input = ="User" andUser_pwd = ="123456": Print("Welcome to login! ") Print(".............") Break Else: Print("incorrect user name or password") I= i + 1
python-Job-2