<jupyter_start><jupyter_text>Lab 07<jupyter_code>class Cab:
    def __init__(self,kms,type_of_cab,year):
        self.__kms = kms
        self.__type_of_cab = type_of_cab
        self.__year = year 
    
    def get_kms(self):
        return self.__kms
    
    def get_type_of_car(self):
        return self.__type_of_cab
    
    def get_year(self):
        return self.__year
    
    def __gt__(self,other):
        return self.__year > other.get_year()
    
    def __eq__(self,other):
        return self.__year == other.get_year() and self.__type_of_cab == other.get_type_of_car()
    
    def __repr__(self):
        print(f"kms: {self.__kms} type of car {self.__type_of_cab} year : {self.__year}")
    
    
class Sedan(Cab):
    def __init__(self,kms,type_of_cab,year):
        Cab.__init__(self,kms,type_of_cab,year)
        self.__price_per_km = 2.5
        
    def calculate_fare(self):
        return Cab.get_kms(self) * self.__price_per_km
    
    
class Hatchback(Cab):
    def __init__(self,kms,type_of_cab,year):
        Cab.__init__(self,kms,type_of_cab,year)
        self.__price_per_km = 2.2
        
    def calculate_fare(self):
        return Cab.get_kms(self) * self.__price_per_km
    
    
s1 = Sedan(10000,'Sedan',2004)
s1.calculate_fare()
s1.get_kms()<jupyter_output><empty_output><jupyter_text>Script<jupyter_code>def read_file(f1):
    file_one = open(f1,'r')
    l = []
    for line in file_one:
        l_split = line.split(';')
        if l_split[0] == "Sedan":
            l.append(Sedan(int(l_split[1]),l_split[0],int(l_split[2])))
        elif l_split[0] == "Hatchback":
            l.append(Hatchback(int(l_split[1]),l_split[0],int(l_split[2])))
    return l

def find_greater(l,cab,year):
    counter_year = 0
    temp_km = 0
    for i in l:
        if cab == 'Sedan':
            if i.get_type_of_car() == cab and i > s1:
                counter_year += 1
        elif cab == "Hatchback":
            if i == h1 :
                temp_km += i.get_kms()
    if cab == 'Sedan':
        return f'There are {counter_year} {cab} cars newer than 2015.'
    else:
        return f'All {cab} cars of {year}  have travelled {temp_km} kms.'
    
    
list_cars = read_file("cabs.txt")
counter = 1
cab = Hatchback(10000,'Hatchback',2020)
s1 = Sedan(10000,'Sedan',2015)
for i in range(len(list_cars)):
    if list_cars[i].get_type_of_car() == "Sedan":
        print("Sedan ",counter, "will pay",list_cars[i].calculate_fare())
        counter += 1
        
print("")
        
print(find_greater(list_cars,"Sedan",2015))

print("")

print(find_greater(list_cars,"Hatchback",2020))<jupyter_output>Sedan  1 will pay 500.0
Sedan  2 will pay 1350.0
Sedan  3 will pay 500.0
Sedan  4 will pay 50.0
Sedan  5 will pay 25.0
Sedan  6 will pay 500.0
Sedan  7 will pay 500.0
Sedan  8 will pay 50.0
Sedan  9 will pay 250.0
Sedan  10 will pay 50.0
Sedan  11 will pay 250.0
Sedan  12 will pay 125.0

There are 7 Sedan cars newer than 2015.

All Hatchback cars of 2020  have travelled 150 kms.
{'fraction_non_alphanumeric': 0.1211314475873544, 'fraction_numerical': 0.045923460898502494, 'mean_word_length': 2.6883435582822086, 'pattern_counts': {'":': 4, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '494402', 'license': 'MIT', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1166, 'n_words': 247, 'path': 'LAB07_BALCI_MustafaCankan/Lab07.ipynb', 'repo_name': 'MustiCankan/PythonProjectsCS', 'size': '3005'}