Question: Python # In this part of the file it is very important that you write code inside # the functions only. If you write code

Python

 Python # In this part of the file it is very

# In this part of the file it is very important that you write code inside # the functions only. If you write code in between the functions, then the # grading system will not be able to read your code or grade your work! 
 def abundant(n): # Fill in your code here for Part 1  return None # Change or replace this line 
if __name__ == "__main__": 
 print('Testing abundant() for 2: ' + str(abundant(2))) print('Testing abundant() for 5: ' + str(abundant(5))) print('Testing abundant() for 10: ' + str(abundant(10))) 

An abundant number is an integer that is less than the sum of its perfect divisors (a perfect divisor is a value that divides a number evenly but is strictly less than the number itself). For example, 12 is an abundant number because its perfect divisors (1, 2, 3, 4, and 6) add up to 16 Complete the abundant function, which takes a single positive integer value n as its argument. The func- tion returns a Python list containing exactly the first n abundant numbers in ascending order. For example, abundant (3) would return a list with the first three abundant numbers. Hint: You will need two loops and several helper variables to solve this problem. Your helper variables (outside the loop) should track (among other things) the number of abundant numbers seen so far as well as the integer currently being examined (which will start at 2 and increase at the end of your outer loop). The first (outer loop should continue until you have found the required number of abundant numbers. Inside that loop, use a second loop to find and add up the perfect divisors of the number currently being examined. Examples: Function Call I Return Value abundant (2) [12, 181 abundant (5) 12, 18, 20, 24, 301 abundant (10) [12, 18, 20, 24, 30, 36, 40, 42, 48, 541

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!