Advertisement
Spocoman

04. Car To Go

Dec 22nd, 2021
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. budget = float(input())
  2. season = input()
  3. car = ''
  4. car_class = ''
  5.  
  6. if budget > 500:
  7.     car = 'Jeep'
  8.     car_class = 'Luxury class'
  9.     budget = 0.9 * budget
  10. elif 100 < budget <= 500:
  11.     if season == 'Summer':
  12.         car = 'Cabrio'
  13.         budget = 0.45 * budget
  14.     else:
  15.         car = 'Jeep'
  16.         budget = 0.8 * budget
  17.        
  18.     car_class = 'Compact class'
  19.  
  20. elif 0 < budget <= 100:
  21.     if season == 'Summer':
  22.         car = 'Cabrio'
  23.         budget = 0.35 * budget
  24.     else:
  25.         car = 'Jeep'
  26.         budget = 0.65 * budget
  27.        
  28.     car_class = 'Economy class'
  29.  
  30. print(car_class)
  31. print(f'{car} - {budget:.2f}')
  32.  
  33.  
  34.  
  35. И малко по-съкратен вариант:
  36.  
  37. budget = float(input())
  38. season = input()
  39. car = 'Jeep'
  40. car_class = 'Luxury class'
  41.  
  42. if budget > 500:
  43.     budget *= 0.9
  44. elif 100 < budget <= 500:
  45.     if season == 'Summer':
  46.         car = 'Cabrio'
  47.         budget *= 0.45
  48.     else:
  49.         budget *= 0.8
  50.  
  51.     car_class = 'Compact class'
  52.  
  53. elif 0 < budget <= 100:
  54.     if season == 'Summer':
  55.         car = 'Cabrio'
  56.         budget *= 0.35
  57.     else:
  58.         budget *= 0.65
  59.  
  60.     car_class = 'Economy class'
  61.  
  62. print(f'{car_class}\n{car} - {budget:.2f}')
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement