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
4 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]4 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
What keyword is used to declare a method in python?
Harrizon [31]
I think the answer is B
8 0
3 years ago
If the ____________ is broken on a laptop, chances are other parts are also broken.
ella [17]
Central processing Unit
8 0
3 years ago
How many bits does it take to represent the values from 0 to 255?
valentina_108 [34]
2^8 = 256 hence use 8 bits
5 0
3 years ago
When programming, which of the following is true of the editor?
OLEGan [10]

Answer:

The correct answer is It is a program that checks for grammatical errors.

Explanation:

In programming, when we want to check that our grammar is correct, we can use an editor.

This is a program that allows you to correct spelling through a software application. It analyzes the entered text and automatically checks whether it is spelled correctly or not, comparing the words with its internal database.

Given this information we can say that the correct answer is It is a program that checks for grammatical errors.

5 0
3 years ago
Design a do-while loop that asks the user
sattari [20]
String answer = new String( "" );
do
{
    System.out.println( "Question? " );
}
while( answer.length > 0 )
5 0
3 years ago
Other questions:
  • What are 3 characteristics of syndrome E?
    13·1 answer
  • A network host with an IP address of 192.168.10.200 wants to send a message to a destination computer with an assigned IP addres
    6·1 answer
  • What is a VIN and what role does it play during a criminal investigation? Explain how a VIN could help in a bomb and/or arson ca
    12·1 answer
  • What is online school like 3 sentences
    8·2 answers
  • Construct a regular expression that recognizes the following language of strings over the alphabet {0 1}:
    10·1 answer
  • How do I answer a question that was answered incorrectly on Brainly
    10·2 answers
  • Compare userNumber with compareNumber and display 'Numbers are not equal' if the numbers are different. Then, display 'Variables
    11·1 answer
  • - Which amongst the following is not a Characteristic of Cloud Computing?
    5·1 answer
  • define the term computer hardware and its various types mentioning 5 examples of IP or devices with one diagram each​
    9·1 answer
  • Disadvantages of a grain crusher
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!