Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def isPrime(n): ''' >>> isPrime(5) True >>> isPrime(1) False >>> isPrime(9) False >>> isPrime(85) False >>> isPrime(1019) True ''' # --- Your code starts here

image text in transcribed
def isPrime(n):
'''
>>> isPrime(5)
True
>>> isPrime(1)
False
>>> isPrime(9)
False
>>> isPrime(85)
False
>>> isPrime(1019)
True
'''
# --- Your code starts here
o Imported From S Instructions: The work in this lab must be completed alone and must be your own. Download the starter code file from the LAB8 Assignment on Canvas. Do not change the function names or given started code on your script. -A doctest is provided as an example of code functionality. Getting the same result as the doctest does not guarantee full credit. You are responsible for debugging and testing your code with enough data, you can share ideas and testing code during your recitation class. -Each function must return the output (Do not use print in your final submission, otherwise your submissions will receive a -1 point deduction) Do not include test code outside any function in the upload. Printing unwanted or ill formatted data to output will cause the test cases to fail. Remove all your testing code before uploading your file (You can also remove the doctest). Do not include the input0 function in your submission. Goal [10 pts] Write the recursive function isPrime(num) that takes an integer as a parameter and returns True if the number is prime, False otherwise. A prime number is a positive integer that has exactly two positive integer factors, 1 and itself - You can assume the function only receives positive integers, return Boolean values -isPrime(num) must be a recursive function, otherwise, no credit is given - If needed, the function could take a second argument, but it will not be provided by the user. This means it should be a preloaded value and the original function call will be fed only withn Remember to consider the special cases - EXAMPLES >isPrime (5) rue >>>isPzime (2) Ealse False >isPrime 19) Eaise Deliverables: Submit your code in a file name LAB8.py to the Lab8 CANVAS assignment before the . MacBook Air

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions