Preparing git repo for final project
This commit is contained in:
21
problems/pset3/fuel/fuel.py
Normal file
21
problems/pset3/fuel/fuel.py
Normal file
@@ -0,0 +1,21 @@
|
||||
def main():
|
||||
while True:
|
||||
fuel = input("Fraction:\t\t")
|
||||
try:
|
||||
x, y = map(int, fuel.split('/'))
|
||||
if x > y:
|
||||
continue
|
||||
result = x / y
|
||||
break
|
||||
except (ValueError, ZeroDivisionError):
|
||||
continue
|
||||
if result <= 0.01:
|
||||
print("E")
|
||||
elif result >= 0.99:
|
||||
print("F")
|
||||
else:
|
||||
print(f"{int(round(result*100, 0))}%")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user