# -*- coding: cp1252 -*- # Matthew Richardson # Period 7 # 1/22/2014 # # RichardsonM_PW2.py # Generate Passwords based on certain user information -------------------------------------------- # USER INFORMATION -------------------------------------------------------------------------------- firstName = "Irad" lastName = "Allen" dateOfBirth = "09/31/1992" idNumber = 515978 # USERNAME ---------------------------------------------------------------------------------------- # USERNAME = <First letter of firstname> + <first letter of lastname> + <idnumber> userName = firstName[0] + lastName[0] + str(idNumber) userName = userName.upper() # PASSWORD ---------------------------------------------------------------------------------------- # Step 1: Multiply the Sum of idNum by 4 and then divide by 2------------------- idNumberList = str(idNumber) idNum1 = idNumberList[0] idNum2 = idNumberList[1] idNum3 = idNumberList[2] idNum4 = idNumberList[3] idNum5 = idNumberList[4] idNum6 = idNumberList[5] idNumSum = int(idNum1) + int(idNum2) + int(idNum3) + int(idNum4) + int(idNum5) + int(idNum6) step1 = (idNumSum * 4) / 2 # Step 2: Multiply the sum of the digits to the year of his birth by 10 and then divide by the month born idYear1 = dateOfBirth[6] idYear2 = dateOfBirth[7] idYear3 = dateOfBirth[8] idYear4 = dateOfBirth[9] idYearSum = int(idYear1) + int(idYear2) + int(idYear3) + int(idYear4) yearDivide = dateOfBirth[0] + dateOfBirth[1] step2 = (idYearSum * 6) / int(yearDivide) # Step 3: Add the digits of step 2 together stringStep3 = str(step2) int1Step3 = stringStep3[0] int2Step3 = stringStep3[1] step3= int(int1Step3) + int(int2Step3) # Step 4: Add the length of FirstName and LastName together firstNameLen = len(firstName) lastNameLen = len(lastName) step4 = int(firstNameLen) + int(lastNameLen) # Step 5: Divide Step1 by Step4 and Multiply by Step 3 step5 = (step1 / step4) step5 = step5 * step3 # Step 6: Multiply the first two digits of IdNum to the last two digits firstOne = idNumberList[0] firstTwo = idNumberList[1] lastOne = idNumberList[4] lastTwo = idNumberList[5] sumFirstTwo = str(firstOne) + str(firstTwo) sumLastTwo = str(lastOne) + str(lastTwo) step6 = int(sumFirstTwo) * int(sumLastTwo) # Step 7: Divide Step 6 by Step 5 step7 = step6 / step5 # Step 8: Divide Step 7 by the lenght of LastName step8 = step7 / len(lastName) # Step 9: Divide Step 1 by Step 8 step9 = step1 / step8 # Step 10: Concatenate (<Step3> + <Step9> + <Step4> + <Step2> + <Step8>) step10 = str(step3) + str(step9) + str(step4) + str(step2) + str(step8) password = step10 print "Username:", userName print "Password:" , password #END--------------------------------------------------------------------------
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question