Queer European MD passionate about IT

fuel.py 468 B

123456789101112131415161718192021
  1. def main():
  2. while True:
  3. fuel = input("Fraction:\t\t")
  4. try:
  5. x, y = map(int, fuel.split('/'))
  6. if x > y:
  7. continue
  8. result = x / y
  9. break
  10. except (ValueError, ZeroDivisionError):
  11. continue
  12. if result <= 0.01:
  13. print("E")
  14. elif result >= 0.99:
  15. print("F")
  16. else:
  17. print(f"{int(round(result*100, 0))}%")
  18. if __name__ == "__main__":
  19. main()