CS50 Python Fuel MessingPython

Python-Programme
Anonymous
 CS50 Python Fuel Messing

Post by Anonymous »

Ich habe ein Problem mit dem Kraftstoffmesser CS50. Mein Code geht nur die Hälfte der Anforderungen durch. Kann mir jemand mit diesem helfen?

Code: Select all

My result while trying to check:

:) fuel.py exists
:) input of 3/4 yields output of 75% - OK
:) input of 1/3 yields output of 33% - OK
:) input of 2/3 yields output of 67% - OK
:) input of 0/100 yields output of E - OK
:) input of 1/100 yields output of E - OK
:) input of 100/100 yields output of F - OK
:) input of 99/100 yields output of F - OK
**:( input of 100/0 results in reprompt - ERROR
expected program to reject input, but it did not**
:) input of 10/3 results in reprompt - OK
**:( input of three/four results in reprompt - ERROR
expected program to reject input, but it did not**
**:( input of 1.5/4 results in reprompt - ERROR
expected program to reject input, but it did not**
**:( input of 3/5.5 results in reprompt - ERROR
expected program to reject input, but it did not**
**:( input of 5-10 results in reprompt - ERROR
expected program to reject input, but it did not**
< /code>
Mein Code: < /p>
def main ():
final_fuel = get_percent()
percent_fuel = round(final_fuel * 100)
if percent_fuel = 99:
print("F")
else:
print(f"{percent_fuel}%")

def get_percent():
try:
while True:
fraction = input("Fuel Fraction: ")
x, y = fraction.split('/')
x = int(x)
y = int(y)
fuel = x/y
if fuel

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post