Python3 is suitable for beginners to learn how to log on to the system by using a bank account.
I. knowledge points used:
1. Combination of for loop and if judgment
2. Use of % s placeholders
3. Use of auxiliary signs (flag spaces)
4. Use of break
Ii. Sample Code:
'''Bank logon system' uname = "bob" passwd = 123 judgment = 0 choice = 2for I in range (3): username = input ("Enter the User Name: ") password = int (input (" enter the password: ") if username = uname and password = passwd: # print ("~~~ Welcome % s to use the bank self-service system ~~~ "% Uname) # % s is the placeholder judgment = 1 break else: if choice! = 0: print ("!!! Login Failed !!! "+" You have "+ str (choice) +" ") else: print ("!!! Login Failed !!! ") Choice = choice-1if judgment = 0: print (" three chances are used up, this card will be frozen for 10 minutes ") # Only prompts, the freeze operation is not written # The second approach # uname = "bob" # passwd = 123 # choice = 2 # for I in range (3 ): # username = input ("Enter the User name:") # password = int (input ("enter the password:") # if username = uname and password = passwd: # print ("~~~ Welcome % s to use the bank self-service system ~~~ "% Uname) # % s is a placeholder ## break # else: # if choice! = 0: # print ("!!! Login Failed !!! "+" You still have "+ str (choice) +" ") # else: # print ("!!! Login Failed !!! ") # Choice = choice-1 # else: # print (" the three chances have been used up, and this card will be frozen for 10 minutes ")##
The above Python3 is a bank account logon system instance suitable for beginners to learn. It is all the content that I have shared with you. I hope you can give us a reference and support the help house.