1answer.
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
german
3 years ago
9

Write a code that makes a 2D square array with 20×20 elements. Fill the array with random numbers initially. Then, "draw" a squa

re in the array by adding a value of 4 to those array elements, and plot it with imshow. The square should be centered and have side lengths of 10 .
Computers and Technology
1 answer:
NemiM [27]3 years ago
4 0

Answer:

Answer explained below. Python language used

Explanation:

The size of the square is of size 10. So assuming zero indexing,

vertical side1 (column Index = 5): row index from 5 to 14

vertical side1 (column Index = 14): row index from 5 to 14

horizontal side1 (row Index = 5): column index from 5 to 14

horizontal side2 (row Index = 14): column index from 5 to 14

Note:

while indexing, data_new[a:b,c] denotes,

row index: a to b-1

column index: c

Similarly data_new[a,b:c] denotes,

row index: a

column index: b to c-1

<u>Code: </u>

import matplotlib.pyplot as plt

import numpy as np

size_1 = 20

size_2 = 20

data_new = np.random.random((size_1,size_2))

data_new[5:15,5] = 4

data_new[5:15,14] = 4

data_new[5,5:15] = 4

data_new[14,5:15] = 4

fig = plt.figure(figsize=(10,10))

plt.imshow(data_new)

plt.colorbar()

plt.show()

You might be interested in
A software development company wants to reorganize its office so that managers and the Computer Programmers they supervise can b
dimaraw [331]
Perhaps instead of cubicles, desks are organized in an open workspace which promotes collaboration (and makes it easier).
7 0
2 years ago
Read 2 more answers
Which property is assigned to a file by the operating system?
Zolol [24]
Your answer would be a type
7 0
3 years ago
4. The Internet may best be compared to a/an A. series of colored lights. B. loud truck motor. C. enormous skyscraper. D. large
Triss [41]
D. Large network of roads.

A resembles a modem/router and C a webserver.
6 0
3 years ago
Which of the actions below will not create more room on your hard drive?
slavikrds [6]
A. defragging your hard drive
4 0
2 years ago
With ____ editing, Word automatically displays a Paste Options button near the pasted or moved text.
harina [27]
The answer is drag and drop. 
 With drag and drop editing, word automatically displays a paste option button near the pasted or moved text. 
8 0
3 years ago
Other questions:
  • The IP address 129.53.82.20 falls under what class of IP addresses??
    5·2 answers
  • Where does a computer store it’s information
    11·1 answer
  • First write a method to calculate the greatest common divisor (GCD) of two positive integers using Euclid’s algorithm (also know
    10·1 answer
  • .in the array based list implementation of the ADT what is the worst case time efficiency of the getEntry method?
    14·1 answer
  • Consider the following code segment. int[] seq = {3, 1, 8, 4, 2, 5}; for (int k = 1; k &lt; seq.length; k++) { if (seq[k] &gt;=
    5·1 answer
  • Internet is for everyone but it wont be if its users cannot protect their privacy and the confidentiality of transactions conduc
    6·1 answer
  • Does clicking ads and pop ups like the one shown in this image could expose your computer to malware?
    15·1 answer
  • How many report charts can be added to the account page layout to meet this requirement? A sales manager would like to look at a
    14·1 answer
  • What are two types of crust on the earths surface
    15·2 answers
  • Please tell fast plzzzzzzzz​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!