answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Law Incorporation [45]
2 years ago
8

Exercise 9.1.6: Checkerboard, v1 Spoint

Computers and Technology
1 answer:
AysviL [449]2 years ago
8 0

Answer:

In order to get following pattern, we have to use numpy package.

Following code with work perfectly fine and will print the pattern.

Python code starts as below

*********************************************

<em># Python program to print 8 X 8 alternative 1 and 0's. 3rd and 4th row with all 0's </em>

<em># checkerboard pattern using numpy </em>

<em># We need Following pattern </em>

<em># 0 1 0 1 0 1 0 1 </em>

<em># 1 0 1 0 1 0 1 0 </em>

<em># 0 1 0 1 0 1 0 1 </em>

<em># 0 0 0 0 0 0 0 0 </em>

<em># 0 0 0 0 0 0 0 0 </em>

<em># 1 0 1 0 1 0 1 0 </em>

<em># 0 1 0 1 0 1 0 1 </em>

<em># 1 0 1 0 1 0 1 0 </em>

<em> </em>

<em>import numpy as np </em>

<em> </em>

<em># function to print Checkerboard pattern </em>

<em>def printcheckboard(n): </em>

<em> </em>

<em>        print(" Customized Checkerboard pattern:") </em>

<em>        # create a n * n matrix   </em>

<em>        x = np.zeros((n, n), dtype = int) </em>

<em>        y = np.zeros((n, n), dtype = int) </em>

<em>        # fill with 1 the alternate rows and columns </em>

<em>        x[1::2, ::2] = 1 </em>

<em>        x[::2, 1::2] = 1 </em>

<em>       # fill with 0 the alternate rows and columns </em>

<em>        y[1::2, ::2] = 0 </em>

<em>        y[::2, 1::2] = 0 </em>

<em> </em>

<em>        # print the pattern  for first 3 rows</em>

<em>        for i in range(0,3): </em>

<em>                for j in range(n): </em>

<em>                        print(x[i][j], end =" ") </em>

<em>                print() </em>

<em>        # print the pattern   for next two rows with all 0's</em>

<em>        for k in range(3,5): </em>

<em>                for l in range(n): </em>

<em>                        print(y[k][l], end =" ") </em>

<em>                print() </em>

<em>         # print the pattern  for last 3 rows with alternative 1 and 0.        </em>

<em>        for i in range(5,8): </em>

<em>                for j in range(n): </em>

<em>                        print(x[i][j], end =" ") </em>

<em>                print() </em>

<em> </em>

<em># Calling the function code </em>

<em>n = 8 </em>

<em>printcheckboard(n)</em>

**************************************

End of the Python Code.

Explanation:

In this you have to use Python3.7 and numpy should be installed as well in order to execute the code successfully.

2 D matrix will be created using Python numpy library and checkboard pattern is generated using array slicing.

Here n=8 and it will generate the checkerboard pattern of alternative 0 and 1. However, we need row 4th and 5th as all 0. So we have initialized two arrays matrix as x and y.

Comments in the code is self explanatory.

PS: Please make sure code is edited in IDE so that tabs or space issues can be taken care.

You might be interested in
A large software development company employs 100 computer programmers. Of them, 45 areproficient in Java, 30 in C, 20 in Python,
melisa1 [442]

Answer:

18, 13, 19

Explanation:

Number of computer programmers proficient only in Java = 45 - ( 1+1+6) = 37

Number of computer programmers proficient only in C++ = 30 - (6+1+5) = 18

Number of computer programmers proficient only in python = 20 - ( 1+1+5) = 13

Number of computer programmers are not proficient in any of these three languages = 100 - ( 37 + 18 + 13 + 1+ 1+ 5+ 6 ) = 100 - 81 = 19

4 0
2 years ago
Find true or false. A hacker is hacking software with access in sensitive information from your computer​
Alina [70]
ITS TRUE!!I SEARCHED IT
7 0
1 year ago
Into which of these files would you paste copied information to create an integrated document?
Oksanka [162]
D cause you will need to keep up with data also
7 0
2 years ago
Read 2 more answers
A slide in Blake's presentation contained the following information:
deff fn [24]

Answer:

consistent phrasing is missing

Explanation:

If you will note carefully, the bullets are not in correct format. The model is missing. The correct one is as below.

Risks

The correct form of presentation is as below:

1. Risks

a. employees  

              a. physical illness

              b. mental illness

              c. death  

2. Customers  

              a.   complaints

              b.   downtime

3.  Benefits

However, the content seems to be complete now, and hence not anything else is required. And since its not something very tough to decide to go with, bite the bullet is certainly not an issue.  

3 0
2 years ago
Which of the following statements are true. .ascii stores string in memory and terminate it with NULL character. There is no way
Tems11 [23]

Answer:

The true statements are:

There is an assembler directive to arrange / place floating point values in static data memory

MARS always uses setting '.set boat'

Explanation:

It is the assembler directive who arranges and places the floating point values for the static data memory. Obviously there is no such way for the MIPS assemble programming for reservation of the static data memory without having any initialization for a considerable value.

MARS would definitely use the setting set “noat” ascii would store the string in the memory and then terminate it with respect to NULL character. They cannot reserve the MIPS assembly programming for a considerable value.

4 0
2 years ago
Other questions:
  • Ben's team is working on an English project. The members want to see everyone's progress on their part of the project. What tech
    7·2 answers
  • Why is continual user involvement a useful way to discover system requirements? Under what conditions might it be used? Under wh
    5·1 answer
  • Identify the normalized form of the mantissa in 111.01.
    14·1 answer
  • Consider the following code: x = 17 y = 5 print (x % y) What is output?
    10·1 answer
  • rite a method so that the main() code below can be replaced by simpler code that calls method calcMilesTraveled(). Original main
    7·1 answer
  • CodeHS Python Rainforest Exercise 5.4.7: Categories
    12·1 answer
  • _____ is a markup language designed to transport and store data on the Web. Group of answer choices Standard Generalized Markup
    13·1 answer
  • Describe the indicators and hazards of a metal deck roof fire in an unprotected steel joist warehouse as well as the techniques
    6·1 answer
  • The microprogram counter (MPC) contains the address of the next microcode statement for the Mic1 emulator to execute. The MPC va
    12·1 answer
  • Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!