Python Job Two

Source: Internet
Author: User

1. Assuming that the one-year interest rate is 3.25%, calculate the need for an excessive number of young, 10,000 yuan of one-year fixed deposit with the benefit of doubling

Money = 10000# interest = 0.0325# interest rate count = 0# times  while Money < 20000:    count+=1    money +=money*interest    print( "  Money ", Count,money)


2. Basic requirements: Let the user enter the user name password Authentication successful display welcome information after three times to exit the program upgrade requirements: can support multiple users login (prompt, through the list to save multiple account information) User 3 authentication failed, quit the program, restart the program when attempting to log on, or locked state (hint: Need to save user-locked state to file)

User =[["Alex",'123'],["Shan",'456']]count=0pass_auth_flag= False#flag BitFirst_input_user = None#Remember the first time user nameIs_same_user = True#used to determine if the user name for three inputs is equal#from a filef = open ("Lock_file","R") Lockd_users= [] forLineinchF:lockd_users.append (Line.strip ())#print ("LOCKD User:", lockd_users) whileCount<3: Username= Input ("Username:"). Strip () password= Input ("Password:"). Strip ()ifUsernameinchLockd_users:exit ("User is locked")    if  notFirst_input_user:#If there is no value, it represents the first timeFirst_input_user =usernameifUsername! =First_input_user:is_same_user= False#multiple inputs are not the same user name     for_userinchUser:if_user[0] = = Username and_USER[1] = =Password:Print("Login Successful! [%s] Welcome to enter"%username) Pass_auth_flag= True#Certification Success             Break            #exit ()    Else:        Print("The user name or password is wrong! ")    ifPass_auth_flag isTrue: BreakCount+=1Else:    Print("too many input times")    ifIs_same_user istrue:f= Open ("Lock_file","a") F.write (username+"\ n") F.close ()Print("this user is locked! ", username)



Python Job Two

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.