Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, threading
- success = []
- def add(A, B):
- return "{0:.5f}".format(round(A+B,2))
- def mul(A, B):
- return "{0:.5f}".format(round(A*B,2))
- def test(A, B):
- if(add(A, B) == 6.0 and mul(A, B) == 6.0):
- return True
- else:
- return False
- def threader(A):
- global success
- B = 6.0
- while B > 3.0:
- try:
- if test(A, B):
- print("Found Match: %s : %s" %(A, B))
- success.append([A, B])
- break
- else:
- B-=0.001
- except KeyboardInterrupt:
- print("stopping")
- print("Thread A=%s has finished"%A)
- def main():
- A = 0.0
- while A < 3.0:
- A+=0.001
- print("Starting Thread with A as %s" %A)
- t=threading.Thread(target=threader,args=(A,))
- t.start()
- t.join()
- print(success)
- if __name__ == "__main__":
- try:
- main()
- except Exception as err:
- print("There was an Error:")
- print(err)
- print(success)
- except KeyboardInterrupt:
- print("stopping")
- print(success)
- except:
- print("Something went Wrong")
- print(success)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement