def trash_bins(): amsterdam_api = AmsterdamApi() req = 'A' while req != 'M' and req != 'T': req = input( "Do you want a list of trash bins or monuments? Enter T or M:") if req == 'T': list_trash_bins = amsterdam_api.get_trash_bins() print("Overview of trash bins in Amsterdam") for trash_bin in list_trash_bins: print( str(trash_bin['id']) + "\t" + trash_bin['name'] + "\t" + trash_bin['type'] + "\t" + trash_bin['address']) else: print("Overview of monuments in Amsterdam") list_monuments = amsterdam_api.get_monuments() for monument in list_monuments: print(str(monument['id']) + "\t" + monument['address'])
def main(): amsterdam_api = AmsterdamApi() list_trash_bins = amsterdam_api.get_trash_bins() weightTotal = 0 weightHigh = 0 weightLow = 0 print("Overview of trash bins in Amsterdam") for trash_bin in list_trash_bins: print( str(trash_bin['id']) + "\t" + trash_bin['name'] + "\t" + trash_bin['type'] + "\t" + trash_bin['address'] + "\t" + str(trash_bin['weight']) ) weightTotal += trash_bin['weight'] if trash_bin['weight'] >= weightHigh: weightHigh = trash_bin['weight'] #if trash_bin['weight'] =< weightLow: #weightLow = min(list_trash_bins) print('\nTotal weight is : ' + str(weightTotal)) print('Mean weight is : ' + str(weightTotal/len(list_trash_bins))) print('Highest weight is : ' + str(weightHigh))
def trash_bins(): amsterdam_api = AmsterdamApi() list_trash_bins = amsterdam_api.get_trash_bins() print("Overview of trash bins in Amsterdam") for trash_bin in list_trash_bins: print( str(trash_bin['id']) + "\t" + trash_bin['name'] + "\t" + trash_bin['type'] + "\t" + trash_bin['address'])
def trash_bins(): amsterdam_api = AmsterdamApi() list_trash_bins = amsterdam_api.get_trash_bins() list_monuments = amsterdam_api.get_monuments() print("Overview of trash bins in Amsterdam") for trash_bin in list_trash_bins: print( str(trash_bin['id']) + "\t" + trash_bin['name'] + "\t" + trash_bin['type'] + "\t" + trash_bin['address']) print("\nTotal amount of trash bins : ", len(list_trash_bins)) print("Total amount of Papier trash bins : ", sum(trash_bin['type'] == 'Papier' for trash_bin in list_trash_bins)) print("Total amount of Rest trash bins : ", sum(trash_bin['type'] == 'Rest' for trash_bin in list_trash_bins)) print("Average id number : ", statistics.mean(trash_bin['id'] for trash_bin in list_trash_bins), "\n") for monument in list_monuments: print(str(monument['id']) + "\t" + monument['address'])
def test_api_path(): amsterdam_api = AmsterdamApi() assert amsterdam_api.get_api_path( ) == "https://api.data.amsterdam.nl/", "Should be https://api.data.amsterdam.nl/"