Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python 3 3. (13 points) Write a function chessBoard(m, n) that takes as input two integers m and n, and returns a 100 x 200
python 3
3. (13 points) Write a function chessBoard(m, n) that takes as input two integers m and n, and returns a 100 x 200 NumPy array that represents an m x n black and white chessboard image. We assume that each pixel in the image is represented by a single real number between 0 and 1, representing the gray scale from black to white Note: You should only use Numpy and Matplotlib for this problem. To get full credits, you should avoid using any explicit for/while loops. In [ ]: # run this cell to import necessary modules # DO NOT DELETE import matplotlib.pyplot as plt import numpy as np In [ ]: # put your code here Test your function by running the following cell. In [ ]: # Test your code here # DO NOT DELETE img = chessBoard(5,10) plt.imshow(img, cmap = "gray") plt.show() The resulting image should be similar to the following image: In [1]: # Run the cell to show the test image # DO NOT DELETE from IPython.display import Image, display display (Image("chessBoard_demo.png")) 0 20 40 60 80 0 25 50 75 100 125 150 175Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started