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
NeX [460]
4 years ago
8

In this this problem you will be using for loops to take a matrix of random number and create a new matrix that is the same as t

he random matrix, but with zeros on the diagonal. a) Create matrix m that is a 10x10 matrix of random whole numbers from 1 to 20. You will have to manipulate the random number generator function to modify the interval and get only whole numbers. b) Create a for loop that runs for index i equal to the index for every row in the matrix. Next, create a nested for loop that runs for index j equal to the index for every column in the matrix. This is very similar to the Your Turn - Extra slide of Lecture 13. c) Now, we want to use our for loops to create a new niatrix, n, that is equal to matrix m, but with zeros on the diagonal. You should use an if/else statement to create this new matrix. If the location is on the diagonal (i=j), then the value of matrix n at the location will be zero. Otherwise, the value of matrix n equals the value of matrix m at each location
Engineering
1 answer:
motikmotik4 years ago
5 0

Answer:

import numpy as np

# creating matrix of order 10*10 with random numbers between 1 and 20

m = np.random.randint(1,20, size=(10,10))

# create new matrix which reads matrix m and produces zero along the diagonal

n = np.random.randint(1,20, size=(10,10)) # create new matrix, n

for i in range(0,10): # loop through row of matrix

 for j in range(0,10): # loop through column of the matrix

   if i==j: # check for the diagonal element

     n[i][j] = 0 # asign diagonal value to zero

   else:

     n[i][j] = m[i][j] # assign the value of matrix m to n

# displaying m and n matrix in the given format using disp function

from io import StringIO

buf = StringIO()

np.disp(m,device=buf)

m = buf.getvalue()

m = m[1:-1] #removing the extra [ and ]from beginning and end

print("m = ")

print(m.replace(" [","").replace('[',"").replace(']',""))

buf = StringIO()

np.disp(n,device=buf)

n = buf.getvalue()

n = n[1:-1] #removing the extra [ and ]from beginning and end

print("n = ")

print(n.replace(" [","").replace('[',"").replace(']',""))

Explanation:

You might be interested in
Microstructures are microscopic additions or forms in a system.<br> True<br> O False
Damm [24]

Answer:

True

Explanation:

Microstructure is the very small scale structure of a material, defined as the structure of a prepared surface of material as revealed by an optical microscope above 25× magnification. ...

4 0
3 years ago
Read 2 more answers
The Leaning Tower of Pisa is located in which country? Question 1 options: France Italy The United States Norway
Ket [755]

Answer:

Tuscany, Central Italy

Explanation:

5 0
3 years ago
Read 2 more answers
A 4-kW electric heater runs for 2 hours to raise the room temperature to the desired level. Determine the amount of electric ene
Anna35 [415]

Answer:

Q' = 8 KW.h

Q'=28800 KJ

Explanation:

Given that

Heat Q= 4 KW

time ,t = 2 hours

The amount of energy used in KWh given as

Q ' = Q x t

Q' = 4 x  2 KW.h

Q' = 8 KW.h

We know that

1 h = 60 min = 60 x 60 s  = 3600 s

We know that W  = 1 J/s

The amount of energy used in KJ given as

Q' = 8 x 3600 = 28800 KJ

Therefore

Q' = 8 KW.h

Q'=28800 KJ

6 0
3 years ago
6. True or False? Common materials used in media
erastova [34]

Answer:

its false

i think it is right

4 0
3 years ago
Two added to four times a number, minus 3 times the number, equals 5.
vladimir1956 [14]
<h2>Answer:</h2>

<u>x= 3</u>.

<h2>Explanation:</h2>

<em>What is presented in this problem is basically an equation in verbal form.</em>

<em />

<h3>1. Write the equation.</h3>

2+4x-3x=5

<h3>2. Solve for x.</h3>

2+4x-3x=5\\ \\2+x=5\\ \\x=5-2\\ \\x=3

<h3>3. Express the result.</h3>

x= 3.

8 0
2 years ago
Other questions:
  • A square silicon chip (k = 152 W/m·K) is of width 7 mm on a side and of thickness 3 mm. The chip is mounted in a substrate such
    14·1 answer
  • A multistage pump is required to deliver water to a head of 50 m at flow rate of 0.1 m^3/s. A motor rotating at 1800 rpm is avai
    8·1 answer
  • Which of the following results from the fact that skip signals refracted from the ionosphere are elliptically polarized?
    14·1 answer
  • True/False<br> An anemometer displays wind direction, wind speed, altitude and type of precipitation
    12·1 answer
  • A certain working substance receives 100 Btu reversibly as heat at a temperature of 1000℉ from an energy source at 3600°R. Refer
    13·1 answer
  • The real power delivered by a source to two impedances, ????1=4+????5⁡Ω and ????2=10⁡Ω connected in parallel, is 1000 W. Determi
    14·1 answer
  • Draw a sinusoidal signal and illustrate how quantization and sampling is handled by
    8·1 answer
  • What are some things that AREN’T manufactured
    15·1 answer
  • He is going ___ in the hot air ballon​
    6·1 answer
  • Traveling a average speed at 55mph how many miles will you travel in9 hours
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!