Question
I need fix the print in my python please help my code is https://codeshare.io/5ZD7Xo my print Prime factors of 10 are 2 5 how can
I need fix the print in my python please help
my code is https://codeshare.io/5ZD7Xo
my print Prime factors of 10 are 2 5 how can I fix Prime factors of 10 are 2, 5
and I want one more error Invalid input for not this primes=="Y"or primes=="N"
my code
def sqrt(num): ret = num**(1/2.0) return int(ret)
def printprime(num): ret = False for i in range(2, num + 1): prime = True if num % i == 0: for j in range(2, sqrt(i)+1): if i % j == 0: prime = False break if prime: print(i, end=" ") ret = True if not ret: print("No Prime Divisors")
def main_function(): 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: print("Prime factors of",pnum,"are",end=" ") ret = printprime(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.")
main_function()
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