Question: The following function is meant to determine if a given integer is prime ( meaning it is only evenly divisible by 1 and itself )

The following function is meant to determine if a given integer is prime (meaning it is only evenly divisible by 1 and itself). For instance, is _prime (11) should return True, while is prime(12) should return
False (because 12 is divisible by 2,3,4, and 6). The code does this by creating a list of the prime numbers upto (and including) the inputed integer and then checking if the inputed integer is in that list.
The code has 4 errors. Your job is to tell me the line number of each of the errors. Note: there can be multiple errors on the same line. If the line has more than 1 error, you should communicate that
information to me (list the line 3 times if the same error appears there 3 times or you can say line 5 has 3 errors). You can tell me what the error is or how to fix it or something else. If you do give me a
reason for the error, then yeu can earn full credit even if we disagree on the line number (my numbers are all where the code has a. problem, not necessarily where the interpreter will fire the exception).
However, if you do give me a reason, then I will count off points if your reasoning is wrong (even if you tell me the correct line).
The code is as follows:
def is_prime(x):
primes ="
for y in range(2, x+1):
prime_flag = False
for prime in primes:
if y % prime ==0:
prime_flag = False
if prime_flag:
primes +=[y]
return primes[-1]

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!