Congratulations! You’ve just been hired by the FBI, and your boss needs your hel
ID: 3581631 • Letter: C
Question
Congratulations! You’ve just been hired by the FBI, and your boss needs your help unlocking a criminal’s iPhone. The default iPhone passcode is exactly 4 digits long, each between 0 and 9. Assume someone else has already written a function test_password that takes a single string argument representing a possible passcode (with a length of exactly 4 characters.) test_password returns True if the input passcode unlocks the phone and False otherwise. Write a Python function crack_iphone that takes no arguments and returns a string representing the passcode that unlocks the phone. CAUTION: The string "0" is not a possible passcode, but "0000" is.
Explanation / Answer
#!/usr/bin/python
import random
def crack_iphone():
passcode =''
for num in range(0,4):
passcode += str(random.randrange(0,9));
return passcode;
# add your code here
# below is a sample code
print "Passcode Breaker"
guess_code = crack_iphone()
print guess_code;