Imagine you forgot your 4 digit passcode for your phone, and you need to guess the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Imagine you forgot your 4 digit passcode for your phone, and you need to guess the correct passcode. 9:41 AM ***** 1 4 GHI 7 PORS Enter Passcode Emergency NL ) ( 00 2 3 ABC DEF 5 8 O 6 MNO 9 WXYZ Cancel Write a program to guess passcodes for you that will speed up the process. The secret passcode has been randomly generated and is stored inside a variable called secret_passcode. Starting with 0000, guess every possible passcode all the way up to 9999. Once the correct passcode has been guessed, print out how many guesses it took to reach the correct one. 1 4N34 in 6 2 7 8 8.10.8: Guess the Passcode 5 The passcode is randomly generated and stored in the variable secretPasscode. Print out how many guesses it took to guess the correct passcode. 9 10 import random 11 Write a program that guesses every possible 4 digit passcode combinations until the correct passcode is guessed. 12 # Checks whether the given guess passcode is the correct passcode 13 def is correct (guess_code, correct_code): 14 return guess_code == correct_code 19 20 - 21 15 16 # Generates a random 4 digit passcode and returns it as a String 17 def generate_random_passcode(): 18 random_passcode for i in range (4): = random_digit = random.randint(0, 9) random_passcode += str(random_digit) 22 23 24 25 secret_passcode = generate_random_passcode() 26 # Write your code here return random_passcode Imagine you forgot your 4 digit passcode for your phone, and you need to guess the correct passcode. 9:41 AM ***** 1 4 GHI 7 PORS Enter Passcode Emergency NL ) ( 00 2 3 ABC DEF 5 8 O 6 MNO 9 WXYZ Cancel Write a program to guess passcodes for you that will speed up the process. The secret passcode has been randomly generated and is stored inside a variable called secret_passcode. Starting with 0000, guess every possible passcode all the way up to 9999. Once the correct passcode has been guessed, print out how many guesses it took to reach the correct one. 1 4N34 in 6 2 7 8 8.10.8: Guess the Passcode 5 The passcode is randomly generated and stored in the variable secretPasscode. Print out how many guesses it took to guess the correct passcode. 9 10 import random 11 Write a program that guesses every possible 4 digit passcode combinations until the correct passcode is guessed. 12 # Checks whether the given guess passcode is the correct passcode 13 def is correct (guess_code, correct_code): 14 return guess_code == correct_code 19 20 - 21 15 16 # Generates a random 4 digit passcode and returns it as a String 17 def generate_random_passcode(): 18 random_passcode for i in range (4): = random_digit = random.randint(0, 9) random_passcode += str(random_digit) 22 23 24 25 secret_passcode = generate_random_passcode() 26 # Write your code here return random_passcode
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Imagine that you have a program on your cell phone that allows you to walk up to any item in the supermarket and have your phone recognize it and display all the necessary information about the...
-
ABC Inc. is planning to purchase DEF Inc. in one of two ways: (1) By paying $22 per share in cash; or (2) By giving DEFs shareholders two shares in the new combined firm ABC-DEF for each share of...
-
How many different combinations are possible if 6 substitute workers are available to fill 3 openings created by employees planning to take vacation leave next week?
-
In a given week, 12 babies are born in hospital. Assume that this sample came from an underlying normal population. The length of each baby is routinely measured and is listed below (in cm): 49, 50,...
-
What are the trade-offs involved in the decision of how much inventory the firm should carry? In what way does the cash manager face a similar trade-off?
-
What does it mean when two events are disjoint?
-
Columbus, Inc., issued \(\$ 50,000\) of 10 -year, \(6 \%\) bonds payable on January 1, 2006. Columbus pays interest each January 1 and July 1 and amortizes discount or premium by the straight-line...
-
FlashCo. manufactures 1-GB flash drives (jump drives). Price and cost data for a relevant range extending to 200,000 units per month are as follows: Sales price per unit (current monthly sales volume...
-
Leif is a full - year resident of Oregon. He won $ 1 , 6 5 0 on an Oregon lottery ticket in February, and got lucky again in August with a $ 5 0 0 Oregon lottery ticket win. In November, Leif won...
-
Daniel B. Butler and Freida C. Butler, husband and wife, file a joint return. The Butlers live at 625 Oak Street in Corbin, KY 40701. Dan's Social Security number is 111-11-1112, and Freida's is...
-
Loaned $ 10000 cash to Candace Smith Candace Smith on a one-year, 12% note. And question is Collected the maturity value of the Smith note. Find cash,interest revenue,interest receivable,notes...
-
What is the professor asking: Further analyze the financial ratios and trend analysis to evaluate and make management decisions?
-
Solution A Solution B Solution C function reverse_word(string word) reversed = for letter in word: reversed = letter + reversed return reversed function check_all_palindromes(array arr) if arr[0] ==...
-
Assume the beaver company incurs 30,000 of factory labor costs. of that amount, 26,000 relates to wages payable and 4,000 relates to payroll taxes payable in February. What is the entry to record...
-
To move a box you pull on the handle as indicated in the diagram shown below with a constant force force acting on the box? (5.401 +7.201)N. The mass of the box is m = 9.00 kg. What is the magnitude...
-
Convert (6,897)12 to: 1.01236 code 2. Gray code 3. Hexadecimal number system 4. Base-8 number system 5. 295 code
-
This discussion will be on the required reading, Big Data, Analytics, and the Path from Insights to Value. Please complete this reading before answering one of the prompts and responding to your...
-
Identify the source of funds within Micro Credit? How does this differ from traditional sources of financing? What internal and external governance mechanisms are in place in Micro Credit?
-
Use Equation (7.35) (page 541) to derive the formula Equation (7.35) 1 (x) i=1
-
There are two fuses in an electrical device. Let X denotes the lifetime of the first fuse, and let Y denote the lifetime of the second fuse (both in years). Assume the joint probability density...
-
Let X Geom(p). Find the MLE of p.
-
The term azeotrope means (a) Condensing without changing (b) Boiling without changing (c) Both (a) and (b) (d) Neither (a) nor (b).
-
The bubble point and dew point curves meet where the mixture turns into (a) Purely two components (b) Purely one component (c) Purely three components (d) None of these.
-
The boiling point diagram of a binary solution is used to know how the equilibrium changes with (a) Pressure (b) Free energy (c) Temperature (d) Entropy.
Study smarter with the SolutionInn App