Starting from:

$30

CT5132/CT5148 Lab Week 01 Solved




1.   Have you installed Anaconda (or a different method of Python installation, if you are confident)?

2.   Are you able to run Python code in the following scenarios?

•    Spyder

•    Jupyter Notebook

•    IPython

•    Command-line (Powershell, Terminal, ...)

3.   In the Grid Driving notebook, we have doctests for simulate() and plan(). Can you run the doctests and observe that they fail?

4.   Let’s work on simulate(). We need to track how many cells have been visited. But to do that, we need to track which cells have been visited. Why? What data structure might we use to track which cells have been visited? Why? Write out a complete implementation for simulate(). When you think you have it right, try the doctests.

5.   Write an extra function draw which outputs a simple text-based diagram of the cells visited by a car. Hint: the following code shows how to create an empty city grid g and then “visit” a particular cell, and then print the grid. Don’t worry if you don’t understand it all yet.

xsize = 10 ysize = 10 g = [[0 for _ in range(xsize)] for _ in range(ysize)] g[4][6] = 1

for line in reversed(g): print(line)

6.   Write out an implementation of plan(), check it with the doctests, and feed its output to draw() and to simulate().

1

More products