Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def printsection1(animals, station1, station2):
- for animal in animals:
- print(animal,' ',station1.get(animal, 0),' ',station2.get(animal, 0))
- def printsection2(animals, station1, station2):
- for animal in animals:
- if station2.get(animal, 0)+station1.get(animal, 0) >= 4:
- print(animal)
- def printsection3(animals, station1, station2):
- for animal in animals:
- print(animal,' ',int(station1.get(animal, 0))+int(station2.get(animal, 0)))
- def printsection4(items):
- import statistics
- most_visits=[]
- for animal, date, station in items:
- most_visits.append(date[0:2])
- print(statistics.mode(most_visits))
- outfile.write("Number of times each animal visited each station:n")
- outfile.write("Animal ID Station 1 Station 2 n")
- printsection1(animals, station1, station2)
- outfile.write('n')
- outfile.write("============================================================ n")
- outfile.write("Animals that visited both stations at least 4 times n")
- printsection2(animals, station1, station2)
- outfile.write('n')
- outfile.write("============================================================ n")
- outfile.write("Total number of visits for each animal n")
- printsection3(animals, station1, station2)
- outfile.write('n')
- outfile.write("============================================================ n")
- outfile.write("Month that has the highest number of visits to the stations n")
- printsection4(items)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement