Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- z = input("enter percentage(don't include %): ")
- x = float(z) / 100 #decimal value
- y = 0.0001 #Minimum difference as close to 0 as possible
- found = False
- for a in range(1, 1001):
- for b in range(1, 1001): #Nested for, so that innerloop iterates completely for every iteration for the outer loop
- if abs((a / b) - x) <= y:
- print(f" {z}% = {a} / {b}")
- found = True
- break
- if found:
- break
Add Comment
Please, Sign In to add comment