Question: code in python please S/debugging.ipynb er debugging Last Cheokpoint: 26 minutes ago (autosaved) t View Insert Cell Kernel Widgets Help validate [10]: # This code
code in python please
S/debugging.ipynb er debugging Last Cheokpoint: 26 minutes ago (autosaved) t View Insert Cell Kernel Widgets Help validate [10]: # This code should accept a positive nonzero integer from the user. # It should then calculate all integral factors of that number. # The following code contains NOT LESS THAN FIVE bugs. # It should pass the following test cases: 190 > 100, 50, 25, 20, 18, 5, 4, 2, 1 69 69, 23, 3, 1 14.5 should be rejected (not raise exception) #a -should be rejected (not raise exception) #eshould be rejected (not raise exception) def is divisible( a, b) Determine if integer a is divisible by integer b. remainder a % b # if remainder is zero, then a is divisible by b return remainder def find divisorsf integer): Find all divisors of an integer and return them as a list. divisors 1 # we know that an integer divides itself divisors.append (integer) # we also know that the biggest divisor other than the integer e itself must be at most half the value of the integer divisor integer / 2 while divisor 0: if is_divisible(integer, divisor): divisor-1 divisors.append (divisor) return divisors def main): input ainput (') # do some checking of the user's input 05/debugging.lpynb ter debugging Last Checkpoint: 27 minutes ago (autosaved View Insert Cell Kernel Widgets Help HRun.Ic code validate we know that an integer divides itself divisors.append(integer) # we also know that the biggest divisor other than the integer # itself must be at most half the value of the integer divisor integer / 2 while divisor-0: if is divisible(integer, divisor): divisor1 divisors.append (divisor) return divisors def main): input-a-input ( , a-') do some checking of the user's input # is it a number? if input a.isalnum): a- int(input a) else: print( Please enter an integer. # 15 it nonnegative? if a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
