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
marianne needs to create a version of her slide presentation that does not include all the slides and will be used for a particu
Art [367]

Answer:

Marianne needs to create a version of her slide presentation that does not include all the slides and will be used for a particular audience. What is the best way for her to achieve this? A.) Use the Custom Show dialog box to create a new custom show

4 0
3 years ago
You have been tracking your exercise routine, which involves running, lifting weights, yoga, and stretching. You want to see wha
Harrizon [31]

The best chart to see the data distribution for the exercise routine would be a pie chart. Using Microsoft Excel, you can input each data point you have for all you exercise routine category, and generate a pie chart which will show you the percentage for each category in comparison to the total.


5 0
4 years ago
Read 2 more answers
. Why should we favor programming to interfaces over implementations?
xenn [34]

Answer:

Interfaces are way to use full abstraction.That;s why it is preffered over implementations.

Interfaces are just like class.But the methods declared inside an abstract class are by default abstract and the variables are by default static,final.Which is not the case with classes in classes the variables can be static or non- static ,fincal or non-final and methods can be abstract or non-abstract.

Java classes does not support multiple inheritance but interfaces support multiple inheritance.So whenever we want to implement multiple inheritance in Java we use interfaces.

4 0
3 years ago
Its not letting me change my email, any way to fix this? Must include steps and how to fix this. (I am using a school email) ANS
AlexFokin [52]
You see, you just aren’t philosophical enough to understand an email. You don’t change the email, it changes you.
3 0
2 years ago
Consider the following code: x = int(input("Input an integer: ")) if (x &gt;= 0): print("Yay!") else: print("Boo!") It outputs "
Fed [463]
<h2>You have to apply the given condition in if loop.</h2>

Explanation:

if((x>=0) && (x%2==0))  

print("Yay!")

else

print("Boo!")

if((x>=0) && (x%2==0))  this statement is enough to check given expectation. the value of x is positive that is checked using  x>=0 and also the positive integer should be an even number is checked using the condition (x%2==0). The "&&" operator is used to check whether both the condition is true. So if the value of "x" is positive and even, "Yah!" will be printed. Otherwise "Boo!" will be printed.

All the other choice goes invalid becoz (x%2==1) will be true only if the number is an odd number.

7 0
3 years ago
Other questions:
  • whats something that u want to do but ur parents wont allow it like having a phone or going to a college ​
    11·2 answers
  • When an object is instantiated, it receives its own copy of all static variables of the class?
    14·1 answer
  • Typically, when an organization purchases Internet access from an Internet Service Provider (ISP), the ISP will grant it
    10·1 answer
  • You notice that it’s very easy to confuse medications at the community health center where you’re working. They are lined up on
    10·1 answer
  • Which two of the following skills are important for a meteorologist
    12·1 answer
  • What are some examples of how AutoFormat can convert text as you type? Check all that apply.
    8·1 answer
  • Edhesive 8.5 code Practice help me pls
    15·1 answer
  • DRAG DROP -A manager calls upon a tester to assist with diagnosing an issue within the following Python script:#!/usr/bin/python
    11·1 answer
  • Please help I’ll mark brainliest!
    12·2 answers
  • Define a SCHEME function, unzip, which takes a list of pairs ((a .b)... (an .bn)) and returns a pair consisting of the two lists
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!