Question: In this assignment, you are going recode the factors function in Assignment 3 using Python to find the proper factors of a number using list

In this assignment, you are going recode the factors function in Assignment 3 using Python to find the
proper factors of a number using list comprehension.
Given a positive integer value n, a proper factor of n is defined to be an integer value i between 1 to n
(exclusively) such that n is divisible by i; that is, the remainder of dividing n by i is zero (0). Note that although
n is divisible by both 1 and n, they are not proper factors of n.
The function factors has the following signature:
def factors(n):
This function should return a list of unique integer values. The elements in the list are all proper factors of the
parameter, and they must be in ascending order.
Here are some examples:
factors (843)[3,281]
factors (3281)[17,193]
factors (6912)[2,3,4,6,8,9,12,16,18,24,27,32,36,48,54,64,
72,96,108,128,144,192,216,256,288,384,432,576,
768,864,1152,1728,2304,3456]
factors (6693)[3,23,69,97,291,2231]
factors (2778)[2,3,6,463,926,1389]
factors (4027)[]
Note that the output for the last example is an empty list since 4,027 is a prime number and it has no proper
factor.
Download the three files csc207a4.py,csc207a4_tester.py,csc207a4_testdata.py from Canvas
and save them in the same folder. The last two files are the tester program and the testing data file,
respectively. Do not modify these two files. The first file is the file you will work on. Note that you cannot
rename this file and you cannot change the name of the function (otherwise the tester will not be able to pick
up your implementation). However, you can change the name of the parameter if you like.
The file csc207a4.py contains a dummy implementation of the function that always returns an incorrect
value. The contents of this file is listed here for your reference:
Fayetteville State University CSC207 Symbolic Programming Spring 2024
Department of Mathematics Assignment 4 Albert Chan
and Computer Science Due Date: April 14 Page 2 of 3
def factors(n):
return [n]
The tester program will use the test data to test your implementation. It will run a total of 100 test cases. If
your function is implemented correctly, running the tester should produce the following output:
Passed: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,
37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,
55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,
73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,
91,92,93,94,95,96,97,98,99,100]- total 100.
Failed: []- total 0.
0 of 100 test cases passed. Score =20.00 of 20.00
If you would like, you can look up the test data from the file csc207a4_testdata.py. This file defines a
single list named tests, which consists of 100 tuples. Each tuple is a test, and it has 3 values inside:
The first is an integer representing the test id.
The second is the input parameter.
The last is the expected result of calling factors using the input parameters.
The following is the first few lines in the test data file:
# csc207_testdata.py
""" Test data for Assignment 4."""
TESTS =[(1,2464,[2,4,7,...,352,616,1232]),
(2,3288,[2,3,4,...,822,1096,1644]),
(3,9676,[2,4,41,59,82,118,164,236,2419,4838]),
(4,1179,[3,9,131,393]),
(5,4639,[]),
...
Notes:
1. Your program will be tested with similar but different data. The testing results will earn you up to 20
points this is your execution score.
2. There cannot be any import statement in your program otherwise, 20% of your execution score
will be deducted.
3. There can be only one single function (the factors function) defined in the csc207a4.py file. No
other helper function(s) is/are allowed. Please note that you also can neither define a nested function
using this code:
def factors (n):
return [n]
In this assignment, you are going recode the

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 Programming Questions!