Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2.  
  3. person_x = 0.0
  4. universe_size = 100.0
  5. person_speed = 10.0
  6. universe_increment = universe_size
  7. seconds = 0
  8.  
  9. history = []
  10.  
  11. while person_x < universe_size:
  12. history.append((seconds, person_x/universe_size, universe_size-person_x))
  13.  
  14. seconds += 1
  15. person_x += 10
  16. person_x += universe_increment*person_x/universe_size
  17. universe_size += universe_increment
  18.  
  19. history.append((seconds,person_x/universe_size, universe_size-person_x))
  20.  
  21.  
  22. plt.plot([x[0] for x in history], [x[1] for x in history])
  23. plt.xlabel('seconds')
  24. plt.ylabel('percent of universe covered')
  25. plt.show()
  26.  
  27. plt.plot([x[0] for x in history], [x[2] for x in history])
  28. plt.xlabel('seconds')
  29. plt.ylabel('absolute distance from end')
  30. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement