In: Computer Science
create a new Python 3 Jupyter Notebook..
Create one python code cell for the problem below. Use any additional variables and comments as needed to program a solution to the corresponding problem. All functions should be defined at the top of the code in alphabetical order.
Problem:
Rubric:
PYTHON CODE:
def num_matches_num(number):
'''
This function is used to check a number which
matches with another number.
It must accept one parameter, which is the
number it will be checking.
'''
# variable to store the birth month prepended to
birth year
month_year=101995%555
# checking parameter matches the month_year
variables
if number == month_year:
# if matches, return
True
return True
else:
# if not matches,
return False
return False
def guess_passcode(small=0,large=100):
'''
This function is used to guess a passcode.
It must accept two parameters, both with default
values.
The first parameter will be for the smallest
number to check and its default value will be 0.
The second parameter will be for the largest
number to check and its default value will be 100.
'''
# variable to store the passcode
passcode = None
# list of numbers in the range of small to
large
lst=list(range(small,large+1))
# looping through every number in the
lst
for i in lst:
# calling the
function with parameter and
# returned value is
stored in the variable 't'
t =
num_matches_num(i)
# if t is true,
assign i to passcode and break from the loop
if t == True:
passcode = i
break
# returning the passcode
return passcode
# calling the function with large parameter
passcode = guess_passcode(large=555)
# printing the passcode
print('Your passcode is {0:d}.'.format(passcode))
SCREENSHOT FOR CODING:
SCREENSHOT FOR OUTPUT: