Spocoman

08. Fuel Tank

Dec 18th, 2021 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. fuel = input()
  2. liter = float(input())
  3.  
  4. if fuel == "Diesel" or fuel == "Gasoline" or fuel == "Gas":
  5.     if liter >= 25:
  6.         print(f'You have enough {fuel.lower()}.')
  7.     else:
  8.         print(f'Fill your tank with {fuel.lower()}!')
  9. else:
  10.     print('Invalid fuel!')
  11.  
  12.  
  13. Или с тернарен оператор:
  14.  
  15. fuel = input().lower()
  16. liter = float(input())
  17.  
  18. if fuel in ("diesel", "gasoline", "gas"):
  19.     print(f'You have enough {fuel}.' if liter >= 25 else f'Fill your tank with {fuel}!')
  20. else:
  21.     print('Invalid fuel!')
  22.  
  23.  
  24. Или тарикатската:)
  25.  
  26. fuel = input().lower()
  27.  
  28. print((f'You have enough {fuel}.' if float(input()) >= 25 else f'Fill your tank with {fuel}!')
  29.       if fuel in ("diesel", "gasoline", "gas") else 'Invalid fuel!')
  30.  
Add Comment
Please, Sign In to add comment