Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. def printsection1(animals, station1, station2):
  2. for animal in animals:
  3. print(animal,' ',station1.get(animal, 0),' ',station2.get(animal, 0))
  4.  
  5. def printsection2(animals, station1, station2):
  6. for animal in animals:
  7. if station2.get(animal, 0)+station1.get(animal, 0) >= 4:
  8. print(animal)
  9.  
  10. def printsection3(animals, station1, station2):
  11. for animal in animals:
  12. print(animal,' ',int(station1.get(animal, 0))+int(station2.get(animal, 0)))
  13.  
  14. def printsection4(items):
  15. import statistics
  16. most_visits=[]
  17. for animal, date, station in items:
  18. most_visits.append(date[0:2])
  19.  
  20. print(statistics.mode(most_visits))
  21.  
  22. outfile.write("Number of times each animal visited each station:n")
  23. outfile.write("Animal ID Station 1 Station 2 n")
  24. printsection1(animals, station1, station2)
  25. outfile.write('n')
  26. outfile.write("============================================================ n")
  27.  
  28. outfile.write("Animals that visited both stations at least 4 times n")
  29. printsection2(animals, station1, station2)
  30. outfile.write('n')
  31. outfile.write("============================================================ n")
  32.  
  33. outfile.write("Total number of visits for each animal n")
  34. printsection3(animals, station1, station2)
  35. outfile.write('n')
  36. outfile.write("============================================================ n")
  37.  
  38. outfile.write("Month that has the highest number of visits to the stations n")
  39. printsection4(items)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement