Exemplo n.º 1
0
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'])
Exemplo n.º 2
0
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))
Exemplo n.º 3
0
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'])
Exemplo n.º 4
0
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'])
Exemplo n.º 5
0
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/"