Question

In: Computer Science

Need to modify the below code to return the time in minutes instead of seconds. (Using...

Need to modify the below code to return the time in minutes instead of seconds.

(Using Python 2.7.6 )

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.")

Solutions

Expert Solution

# Below highlighted lines are modified. Since a minute has 60 seconds, divided the returning value by 60.

import math

def numberPossiblePasswords(numDigits, numPossiblePerDigit):
    numPasswords = numPossiblePerDigit**numDigits
    return numPasswords

def maxSecondsToCrack(numPossiblePasswords, secPerAttempt):
    time = numPossiblePasswords*secPerAttempt
    return math.ceil(time/60)

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) + " minutes maximum to crack the password.")

# Hit the thumbs up if you are fine with the answer. Happy Learning!


Related Solutions

Write a C++ code that can convert time into hours, minutes, seconds. It can accept (seconds),...
Write a C++ code that can convert time into hours, minutes, seconds. It can accept (seconds), (minutes, seconds), (hours, minutes, seconds) The input can be written in main It should produce the following output: (67.4, 14, 5) is 67 Hours, 38 Minutes, 5 Seconds (127.86) is 0 Hours, 2 Minutes, 8 Seconds (-3, 73, 2) is -1 Hours, -46 Minutes, -58 Seconds
Write a program that request a time interval in seconds and display it in hours, minutes,...
Write a program that request a time interval in seconds and display it in hours, minutes, second format. (java)
I need to modify the following code (using Python3), where Groceries.csv is of following form (Item...
I need to modify the following code (using Python3), where Groceries.csv is of following form (Item on 1st column, price on 2nd) Stewing beef,15.45 Ground beef,11.29 Pork chops,11.72 Chicken,7.29 Bacon,7.12 Wieners,4.33 Canned salmon,5.68 Homogenized milk,5.79 Partly skimmed milk,5.20 Butter,4.99 Processed cheese slices,2.53 Evaporated milk,1.89 Eggs,3.11 Bread,2.74 Soda crackers,3.27 Macaroni,1.45 Flour,4.54 Corn flakes,5.72 Apples,4.71 Bananas,1.56 Oranges,3.70 ... a. In the function createPricesDict(), create a dictionary of each product mapped to its price. b. Suppose we have another dictionary for our cart...
Modify the code below to implement the program that will sum up 1000 numbers using 5...
Modify the code below to implement the program that will sum up 1000 numbers using 5 threads. 1st thread will sum up numbers from 1-200 2nd thread will sum up numbers from 201 - 400 ... 5th thread will sum up numbers from 801 - 1000 Make main thread wait for other threads to finish execution and sum up all the results. Display the total to the user. #include <pthread.h> #include <stdio.h> #include <stdlib.h> #define N_OF_THREADS 4 void * print(void...
Modify the following code to use 'envp' instead of 'environ'. Be sure that you understand how...
Modify the following code to use 'envp' instead of 'environ'. Be sure that you understand how the code works. Provide liberal comments to explain what your pointer arithmetic is computing. Also, answer the following questions and explain your answers: i) WHERE in process memory is it most likely that each of the values exist at run time? ii) WHERE in process memory is it most likely the actual strings containing environment variables are stored? #include #include extern char **environ; //...
Design a clock display to show the time in hours, minutes, and seconds. Assume that we...
Design a clock display to show the time in hours, minutes, and seconds. Assume that we have a clock of exactly 1 KHz (1000 clock pulses per second). It will use 6 seven-segment displays and operate either in military time (hours 00 to 23) or regular time (1 to 12, with AM and PM). An input line, x, differentiates between the two. A seventh display is used to show A or P in the latter case; it is blank otherwise....
// If you modify any of the given code, the return types, or the parameters, you...
// If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // You are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of employees struct employeeList {    struct employee* employee;    struct employeeList* next; } *list = NULL;              ...
Time Remaining 5 minutes 19 seconds 00:05:19 Item 23 Item 23 Time Remaining 5 minutes 19...
Time Remaining 5 minutes 19 seconds 00:05:19 Item 23 Item 23 Time Remaining 5 minutes 19 seconds 00:05:19 On April 1st, Bob the Builder entered into a contract of one-month duration to build a barn for Nolan. Bob is guaranteed to receive a base fee of $5,800 for his services in addition to a bonus depending on when the project is completed. Nolan created incentives for Bob to finish the barn as soon as he can without jeopardizing the structural...
Time Remaining 46 minutes 30 seconds 00:46:30 Item 7 Item 7 Time Remaining 46 minutes 30...
Time Remaining 46 minutes 30 seconds 00:46:30 Item 7 Item 7 Time Remaining 46 minutes 30 seconds 00:46:30 On Dec 31, 20X2, the end of the year, Schubert Co. had the following stockholders’ equity. You have been given the ending balances for the year and asked to compute the balances as of the beginning of the year. 9% Preferred Stock, $40 par $   600,000 Common Stock, $8 par $   960,000 Add’l PIC $1,355,000 Retained Earnings $1,255,000 Treasury Stock, 4,000 shares...
Using Quartus to design a stopwatch that can display tenths of seconds, minutes, and hours, with...
Using Quartus to design a stopwatch that can display tenths of seconds, minutes, and hours, with the gaps between HEX displays splitting the time units (i.e. minutes on HEX[5..4], hours on HEX[7..6]). Have the stopwatch cycle through 3 states of a state machine with a pushbutton. The 3 states are counter-clear, counter-start, and counter-stop
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT