Modify the following Python code so that instead of returning the time in second
ID: 3876982 • Letter: M
Question
Modify the following Python code so that instead of returning the time in seconds, it returns the time in minutes.
def numberPossiblePasswords(numDigits, numPossiblePerDigit):
numPasswords = numPossiblePerDigit**numDigits
return numPasswords
def maxSecondsToCrack(numPossiblePasswords, secPerAttempt):
time = numPossiblePasswords*secPerAttempt
return time
nd = int(input("How many digits long is the passcode? "))
nc = int(input("How many possible characters are there per digit? "))
secondsPerAttempt = .08
npp = numberPossiblePasswords(nd, nc)
totalSeconds = maxSecondsToCrack(npp, secondsPerAttempt)
print("It will take you " + str(totalSeconds) + " seconds maximum to crack the password.”)
Modify the code so that instead of returning the time in seconds, it returns the time in minutes.
Explanation / Answer
def numberPossiblePasswords(numDigits, numPossiblePerDigit):
numPasswords = numPossiblePerDigit**numDigits
return numPasswords
def maxSecondsToCrack(numPossiblePasswords, secPerAttempt):
time = (numPossiblePasswords*secPerAttempt)/60
return time
nd = int(input("How many digits long is the passcode? "))
nc = int(input("How many possible characters are there per digit? "))
secondsPerAttempt = .08
npp = numberPossiblePasswords(nd, nc)
totalSeconds = maxSecondsToCrack(npp, secondsPerAttempt)
print("It will take you " + str(totalSeconds) + " seconds maximum to crack the password.”)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.