#๐ Study help
16 messages ยท Page 1 of 1 (latest)
@alpine ferry
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
I got access to a previous grades' practicaltest paper and I would like to attempt it myself. I'm not sure as to where to start and the educational facilities don't provide answers either
for some reason I can't attach the starter .py code
So, what is your question?
How do I do tasks 1, 2, 3 and 4
It appears that you need access to materials (files?) that are not included here.
yes I will add them here
#demo1.py - demonstration code to start Prac Test 3, Tasks 1 & 2
import random
import numpy as np
import matplotlib.pyplot as plt
from canopy import *
def overlay(g, item):
coords = item.get_topleft()
size = item.get_size()
print(coords, size)
print(f"g[{coords[0]}:{coords[0]}+{size},{coords[1]}:{coords[1]}+{size}] = ({size},{size})")
g[coords[0]:coords[0]+size,coords[1]:coords[1]+size] = item.get_image()[:,:]
def main():
xlim = 60
ylim = 80
grid = np.zeros((ylim,xlim))
grid[0,0] = 10 # updated 11/9
t = Tree((20, 30), "b", 100) # updated 11/9
#t = Tree((random.randint(20, xlim-20),random.randint(20, ylim-20)), 5, 10)
print(t)
plt.imshow(grid)
plt.colorbar() # updated 11/9
plt.scatter(t.get_coord()[0], t.get_coord()[1], c=t.get_colour(), s=t.get_size())
plt.show()
if __name__ == "__main__":
main()
More importantly, you should not be asking "how do I do this?". Rather, you should be aking about a specific problem that you have.
alright, sorry about that I'm just in a bit of a pickle
import numpy as np
import matplotlib.pyplot as plt
from canopy import *
def generateimage(b, s, mshape):
grid = np.zeros((mshape[0]s, mshape[1]s))
print(grid)
for block in b:
(cxstart,rystart) = block.gettopleft() # x,y mapping to column,row
print(block, cx_start, ry_start)
grid[ry_start:ry_start+s,cx_start:cx_start+s] = block.generate_image()[:,:]
return grid
def main():
# there are many ways to set up the assignment, this is an example
blocksize = 20 # each block is a 20x20 square
map_shape = (2,1) # 2 rows of blocks, 1 column
blocks = []
blocks.append(Block(blocksize, (0,0)))
blocks.append(Block(blocksize, (0,blocksize)))
blocks[0].add_item(Tree((10,10), 3, 3))
blocks[0].add_item(Tree((5,15), 3, 3))
blocks[1].add_item(Tree((12,6), 5, 4))
print(blocks[0])
print(blocks[1])
plt.imshow(generate_image(blocks, blocksize, map_shape), vmin=0, vmax=10)
plt.colorbar()
plt.show()
if name == "main":
main() ```
thats demo2
Again: So what is YOUR question?
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.