Question
Write a Python program to input a series of number from user and find Prime factors of each given number using a loop. Program will
Write a Python program to input a series of number from user and find Prime factors of each given number using a loop. Program will ask the user to continue or not each time and if user answers yes ask for the number otherwise stop the program. Hint: You need to use a nested loop.
Must include at least 3 functions.
Example
Do you want to find primes? (Y/N): y
Input any positive number: 10 Prime factors of 10 are 2, 5
Do you want to find primes? (Y/N): y
Input any positive number: A10
Invalid input must be a number.
Do you want to find primes? (Y/N): y
Input any positive number: -10
Inputted value must be a positive number
Do you want to find primes? (Y/N): y
Input any positive number: 125678
Prime factors of 125678 are 2, 7, 47, 191
Do you want to find primes? (Y/N): N
Have a nice day.
my code:
print("Do you want to find primes? (Y/N):", end="") primes = input().upper() while (primes=="Y"): print("Input any positive number:",end="") try: pnum=int(input()) if pnum>=0: pnum=pnum else: print("Inputted value must be a positive number") except: print("Invalid input must be a number.") print("Do you want to find primes? (Y/N):", end="") primes = input().upper()
print("Have a nice day.")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started