0

How to show that a program is being processed?

I made a program on checking if an user-input number is prime or not. However, when I enter large numbers, it takes a considerable amount of time. What sort of code would help to show the user that his number is being checked? The program is as below: from math import sqrt as s from time import time as t def check_prime(p): prime = [p] start = t() if p > 3: for i in range(2, int(s(p)) + 1): if p % i == 0: end = t() print('Time taken is', end - start, 'seconds') prime.remove(p) break else: continue else: pass try: end except: end = t() print('Time taken is', end - start, 'seconds') if p in prime: if p == 2 or p == 3 or (p != 1 and p > 0): return(f'{p} is a prime number') elif p <= 0: return(f'{p} is not in the domain of prime or composite numbers') else: return('1 is neither prime nor composite') else: return(f'{p} is NOT a prime number') while True: p = input('> ') print(check_prime(int(p)))

10th Jun 2018, 4:33 PM
Shohan Dutta Roy
Shohan Dutta Roy - avatar
1 Answer
0
Can you specify where exactly should I put that line, so it keeps printing until the result has been determined? 「HAPPY TO HELP」
10th Jun 2018, 5:30 PM
Shohan Dutta Roy
Shohan Dutta Roy - avatar