Вот мой код test_fuel.py
Код: Выделить всё
from fuel import convert, gauge
import pytest
def test_zero_division():
with pytest.raises(ZeroDivisionError):
convert("2/0")
def test_value_error():
with pytest.raises(ValueError):
convert("cat/cat")
def test_convert():
assert convert("1/2") = 50
assert convert("1/100") == 1
assert convert("99/100") == 99
def test_gauge():
gauge(50) == "50%"
gauge(1) == "E"
gauge(99) == "F"
Код: Выделить всё
def main():
fraction = input("Fraction: ")
f = convert(fraction)
percent = gauge(f)
print(percent)
def convert(fraction):
while True:
try:
numerator, denominator = fraction.split("/")
denominator = int(denominator)
numerator = int(numerator)
percent = int(numerator / denominator * 100)
if percent = 99:
return "F"
# tank is empty
elif percent
Подробнее здесь: [url]https://stackoverflow.com/questions/75377883/check-for-refuel-pset5-fails[/url]
Мобильная версия