GeorgiLukanov87

tax_agency_3vars

Jun 28th, 2022 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.11 KB | None | 0 0
  1. # No1 continue
  2.  
  3. data = input().split(">>")
  4. agency_income = []
  5. for vehicle in data:
  6.     details = vehicle.split(' ')
  7.     type_car = details[0]
  8.     year_car = int(details[1])
  9.     kms_car = int(details[2])
  10.     total_tax = 0
  11.     if type_car == 'family':
  12.         total_tax += 50
  13.         total_tax -= 5 * year_car
  14.         total_tax += (kms_car // 3000) * 12
  15.     else:
  16.         print('Invalid car type.')
  17.         continue
  18.     agency_income.append(total_tax)
  19.     print(f'A {type_car} car will pay {total_tax:.2f} euros in taxes.')
  20.  
  21. print(f'Agency will collect {sum(agency_income):.2f} euros in taxes')
  22.  
  23.  
  24.  
  25. =================================================================================
  26. # No2 continue
  27.  
  28. data = input().split(">>")
  29. agency_income = []
  30. for vehicle in data:
  31.     details = vehicle.split(' ')
  32.     type_car = details[0]
  33.     year_car = int(details[1])
  34.     kms_car = int(details[2])
  35.     total_tax = 0
  36.     if type_car != 'family' and type_car != 'heavyDuty' and type_car != 'sports':
  37.         print('Invalid car type.')
  38.         continue
  39.     elif type_car == 'family':
  40.         total_tax += 50
  41.         total_tax -= 5 * year_car
  42.         total_tax += (kms_car // 3000) * 12
  43.  
  44.     agency_income.append(total_tax)
  45.     print(f'A {type_car} car will pay {total_tax:.2f} euros in taxes.')
  46.  
  47. print(f'Agency will collect {sum(agency_income):.2f} euros in taxes')
  48.  
  49.  
  50. =================================================================================
  51. # No3 bool
  52.  
  53. data = input().split(">>")
  54. agency_income = []
  55. for vehicle in data:
  56.     invalid_car = False
  57.     details = vehicle.split(' ')
  58.     type_car = details[0]
  59.     year_car = int(details[1])
  60.     kms_car = int(details[2])
  61.     total_tax = 0
  62.     if type_car == 'family':
  63.         total_tax += 50
  64.         total_tax -= 5 * year_car
  65.         total_tax += (kms_car // 3000) * 12
  66.     else:
  67.         print('Invalid car type.')
  68.         invalid_car = True
  69.  
  70.     agency_income.append(total_tax)
  71.  
  72.     if not invalid_car:
  73.         print(f'A {type_car} car will pay {total_tax:.2f} euros in taxes.')
  74.  
  75. print(f'Agency will collect {sum(agency_income):.2f} euros in taxes')
  76.  
  77.  
Add Comment
Please, Sign In to add comment