Question

write a function that create a list containing a series of lists that represent positions of a square's grids. Given argument is the width or height of the square eg : >>> square_position...

write a function that create a list containing a series of lists that represent positions of a square's grids. Given argument is the width or height of the square

eg : >>> square_position( height = 2 )

output : [[0,0],[0,1],[1,0],[1,1]]

Please answer it in Python 3.0 . Thanks

  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on Linux [[6, θ], [6,-1],tte, 2], [1, e). [1, 1], [1, 2] positions[ fo

def square_position(side):
        positions = []

        for row in range(side):
                for col in range(side):
                        positions.append([row, col])

        return positions

print(square_position(3))
print(square_position(2))


   Please upvote, as i have given the exact answer as asked in question. Still in case of any issues in code, let me know in comments. Thanks!

Add a comment
Know the answer?
Add Answer to:
write a function that create a list containing a series of lists that represent positions of a square's grids. Given argument is the width or height of the square eg : >>> square_position...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4. Write a function extract(pixels, rmin, rmax, cmin, cmax) that takes the 2-D list pixels contai...

    Please design the function in version 3 of python 4. Write a function extract(pixels, rmin, rmax, cmin, cmax) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list that represents the portion of the original image that is specified by the other four parameters. The extracted portion of the image should consist of the pixels that fall in the intersection of the rows of pixels that begin with row rmin...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT