mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -19,8 +19,8 @@ def play_game():
|
||||
time_answer = float(input("How long does the trip take by car "))
|
||||
except ValueError:
|
||||
print("Please enter a number.")
|
||||
car_time = time_difference*train_speed/(car_speed-train_speed)
|
||||
error_percent = int(abs((car_time-time_answer)*100/time_answer)+.5)
|
||||
car_time = time_difference * train_speed / (car_speed - train_speed)
|
||||
error_percent = int(abs((car_time - time_answer) * 100 / time_answer) + 0.5)
|
||||
if error_percent > 5:
|
||||
print("Sorry. You were off by", error_percent, "percent.")
|
||||
print("Correct answer is", round(car_time, 6), "hours")
|
||||
@@ -36,8 +36,7 @@ def main():
|
||||
keep_playing = True
|
||||
while keep_playing:
|
||||
play_game()
|
||||
keep_playing = input(
|
||||
"\nAnother problem (yes or no) ").lower().startswith("y")
|
||||
keep_playing = input("\nAnother problem (yes or no) ").lower().startswith("y")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user