# Test to see how notebook functions in deepnote. # AUTHOR:Your Name Team 4 Group # COURSE: ISTM 615 # PROGRAM: Team Project chapter 6 # PURPOSE: Create a program to tell whether a number is prime or not and list the factors. # INPUT: The data collected will be an integer from the user. # PROCESS: The program will store the code that gets the user input and displays output in the main function. # The program will display an eror code if the number entered is not in range. # The program will store the code that checks whether the number prime or not using an increment counter. # The program witll list the factors of the number if it is not prime. # The program will ask the user if they want to play again. # Recall main function to run program # OUTPUT: Prime Number Checker # Please enter an integer between 1 and 5000: 5 # 5 is a prime number. # Try again? (y/n): y # Please enter an integer between 1 and 5000: 6 # 6 is NOT a prime number. # It has 4 factors: 1 2 3 6 # Try again? (y/n): y # Please enter an integer between 1 and 5000: 200 # 200 is NOT a prime number. # It has 12 factors: 1 2 4 5 8 10 20 25 40 50 100 200 # Try again? (y/n): n # Bye! # HONOR CODE: On my honor, as an Aggie, I have neither given # nor received unauthorized aid on this academic work. #main module #display function def display_title(): print("Prime Number Checker\n") def prime_checker(number): prime = 1 factors =  if (number < 1 or number > 5000) : number = int(input("Error! Invalid input.\nPlease enter an integer between 1 and 5000: ")) print() prime_checker(number) else: #number is between 1 and 5000 i = 2 #intiialize counter i while i < number: #while number/i has a remainder if (number % i) == 0: #if number has no remainder(divisible by number other than 1 and itself) prime = 0 factors.append(i) #store the value i which divides number with no remaind into the factors list. i += 1 #increase the counter factors.append(number) #add inputted integer into factors list. if prime == 1: #if prime variable remains one number is a prime number number print(number, " is a prime number.") else: #else if prime variable changes to zero print number is not a prime number print(number," is NOT a prime number") print("It has ",len(factors)," factors: ", str(factors)) #print factors of number #main function def main(): display_title() # displays title again = "y" #identifier to start while loop #while loop to iteriate number tries. while again.lower() == "y": value = int(input("Please enter an integer between 1 and 5000: "))#request for input prime_checker(value) #Calulcate the prime number for the input print() again = input("Try again? (y/n): ") #request to try again print() print("Bye!") # goodbye message #checks if current module is the main module if __name__ == "__main__": main()
Prime Number Checker 529 is NOT a prime number It has 3 factors: [1, 23, 529] 256 is NOT a prime number It has 9 factors: [1, 2, 4, 8, 16, 32, 64, 128, 256] Bye!