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]
3 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:
motikmotik3 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
A cylinder with a frictionless piston contains 0.05 m3 of air at 60kPa. The linear spring holding the piston is in tension. The
AleksAgata [21]

Answer:

18 kJ

Explanation:

Given:

Initial volume of air = 0.05 m³

Initial pressure = 60 kPa

Final volume = 0.2 m³

Final pressure = 180 kPa

Now,

the Work done by air will be calculated as:

Work Done = Average pressure × Change in volume

thus,

Average pressure = \frac{60+180}{2}  = 120 kPa

and,

Change in volume = Final volume - Initial Volume = 0.2 - 0.05 = 0.15 m³

Therefore,

the work done = 120 × 0.15 = 18 kJ

4 0
3 years ago
Chad is working on a design that uses the pressure of steam to control a valve in order to increase water pressure in showers. W
Natalija [7]

Answer:

C: Viscosity, the resistance to flow that fluids exhibit

Explanation:

Did it on Edge :)

8 0
3 years ago
6.3.9 A coin was tossed n = 1000 times, and the proportion of heads observed was
4vir4ik [10]

Answer:

No

Explanation:

51 / 100 = 510 / 1000

Chance of getting a head is 1 / 2 of total throws

= 1 / 2 × 1000

= 500 is the probability

and the number of heads was just 10 more the the probability...if the was a greater gap, there would be evidence to say the coin is unfair

4 0
3 years ago
Name three types of large motor vehicles with which you might share the roadway. Explain how you can reduce risk when interactin
alexdok [17]

Answer:

rucks, buses, RVs, trolleys

Explanation:

What are some different types of vehicles that we share the road with?

Driving is a complex task, and for safe driving you need to know not just the rules of sharing the road with other cars, but with variety of other types of vehicles: trucks, buses, RVs, trolleys, motorcycles, bicycles and of course pedestrians.

8 0
2 years ago
4. Lockout/tagout (LOTO) is a safety procedure that ensures dangerous machines are properly shut off and not started up again pr
klemol [59]

Answer:true

Explanation:

5 0
3 years ago
Other questions:
  • Which of the following is not true about Machine Learning?Machine Learning was inspired by the learning process of human beings.
    11·1 answer
  • The type of current that flows from the electrode across the arc to the work is called what?
    5·1 answer
  • A small family home in Tucson, Arizona has a rooftop area of 2667 square feet, and it is possible to capture rain falling on abo
    5·1 answer
  • Air expands through an ideal turbine from 1 MPa, 900 K to 0.1 MPa, 500K. The inlet velocity is small compared to the exit veloci
    10·1 answer
  • What word is typically written at the bottom of a cover letter to indicate an
    12·2 answers
  • When would working with machinery be a common type of caught-in and caught-between<br> hazard?
    6·1 answer
  • List the parts of a manual transmission <br><br> List the parts of a typical clutch assembly?
    14·1 answer
  • According to the video, what are some tasks that Construction Managers perform? Check all that apply.
    9·2 answers
  • A school is playing $0.XY per kWh for electric power. To reduce its power bill, the school installs a wind turbine with a rated
    6·1 answer
  • What is a radio wave made up of? Molecules? Electrons? Other?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!