Program 1: python codes for login program (python code of the logon program), codespython
#improt time module for count down puase timeimport time#set var for loop countingcounter=1#login settingwhile counter<=3: print('please enter username: ') username=input() print('please enter password: ') password=input() #dict for username and password userinf={ 'xiaoweilai':'xiaoweilai', 'python':'123', 'education':'edu123' } #different entering cases if userinf.__contains__(username) and userinf.get(username)==password: print('welcome to python world') break else: print("username/password's error","please try again") counter=counter+1 #error entering for 3 times and forcely stop 10senconds. if counter==3: print('You try it too much times.') counter = 0 while counter <= 10: print(10 - counter) time.sleep(1) counter = counter + 1 counter=0 continue
Read me program description:
Design a login program that requires the user name and password
The user enters the login user name and password, and the background processes the user's user name and password, that is, checks whether the existing user name and the corresponding password in the list are correct. If the input is incorrect, continue the second attempt. If the second attempt is incorrect, continue the third attempt. If the third attempt is incorrect, the system prompts that the input is too many times and suspends the input for 10 seconds, the 10-second countdown is displayed. Try again after the countdown is over. Keep repeating until you enter the correct user name and password. The program ends.
Summary of summary knowledge points:
Time module application, Dictionary application, while loop nested statement, break and continue statement, if else statement.
If you like, contact me. QQ 278857042 please note: python or big data.