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