Program 1: python codes for login program (python code of the logon program), codespython

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.