Dark theme

Synthetic landscape


The following code puts a 2D list on the screen as an image:
matplotlib.pyplot.imshow(list_variable)
matplotlib.pyplot.show()

Write a program, which, rather than reading in landscape data, creates a synthetic landscape, 300x300 pixels, and shows it on the screen. It should have functions to generate:

  1. A flat landscape of height 50.
  2. A landscape that slopes from zero in the West to 299 height in the East (assuming North is the top of the image).
  3. A landscape that slopes from zero in the Northwest to 598 height in the Southeast (assuming North is the top of the image).
Each function should take in the size of the landscape and return a 2D list for deslaying in matplotlib.


Hints and one answer