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
A heat pump operates on a Carnot heat pump cycle with a COP of 12.5. It keeps a space at 24°C by consuming 2.15 kW of power. Det
Vinil7 [7]

Answer:

a) T_{L} = 273.378\,K\,(0.228\,^{\textdegree}C), b) \dot Q_{H} = 26.875\,kW

Explanation:

a) The Coefficient of Performance of the Carnot Heat Pump is:

COP_{HP} = \frac{T_{H}}{T_{H}-T_{L}}

After some algebraic handling, the temperature of the cold reservoir is determined:

T_{H}-T_{L} = \frac{T_{H}}{COP_{HP}}

T_{L} = T_{H}\cdot \left(1-\frac{1}{COP_{HP}}  \right)

T_{L} = (297.15\,K)\cdot \left(1-\frac{1}{12.5}\right)

T_{L} = 273.378\,K\,(0.228\,^{\textdegree}C)

b) The heating load provided by the heat pump is:

\dot Q_{H} = COP_{HP}\cdot \dot W

\dot Q_{H} = (12.5)\cdot (2.15\,kW)

\dot Q_{H} = 26.875\,kW

4 0
3 years ago
Which regulations are related to guard rail height and dimensions and uniformity of stairs?
galina1969 [7]

Answer:

C.

structural safety

Explanation:

Guards protecting floor surfaces must be 36 inches in height, while guards for stairs must be 34 inches in height measured vertically from the tread nosing. A guard may also serve as the required handrail (34 to 38 inches high) provided the top rail meets the requirements for grip size.

4 0
3 years ago
Read 2 more answers
Sam decides to remove his oversized hooded jacket before he works near the pto driveline is it safe or unsafe
Salsk061 [2.6K]
Its safe because it isn't something with electricity
4 0
3 years ago
During an expansion process, the pressure of a gas changes from 15 to 140 psia according to the relation P = aV + b, where a = 5
Dominik [7]

The work done during the process is 359 btu

<u></u>

<u>Explanation:</u>

Given-

P1 = 15psia

P2 = 140 psia

V1 = 7ft³

a = 5 psia/ft³

b = C

P = aV +b

Work done, W = ?

P1 = aV1 + b

15 = 5 (7) + b

b = -20 psia

P2 = aV2 + b

140 = 5 ( V2) - 20

V2 = 32 ft³

The work done by the process is the area under the curve which is trapezoidal.

Therefore,

Work done, W = area of trapezoid

= (P2 + P1 / 2) (V2 - V1)

= ( 140 + 15 / 2 ) ( 32 - 7)

= 1937.5 psia ft³

= 1937.5/ 5.4039 = 359 btu

Therefore, the work done during the process is 359 btu

5 0
4 years ago
Where can you go to find the system requirements?
SSSSS [86.1K]

Answer:c

Explanation:

yea, jus go to the systems help center then youll be confronted with a talks. person n they'll walk u threw it.

8 0
1 year ago
Other questions:
  • A sign erected on uneven ground is guyed by cables EF and EG. If the force exerted by cable EF at E is 46 lb, determine the mome
    13·1 answer
  • An equal-tangent sag vertical curve connects a 1% and 3% initial and final grades, respectively, and is designed for 70 mph. The
    12·1 answer
  • To 3 significant digits, what is the change of entropy of air in kJ/kgk if the pressure is decreased from 400 to 300 kPa and the
    15·1 answer
  • The current in a 20 mH inductor is known to be: 푖푖=40푚푚푚푚푡푡≤0푖푖=푚푚1푒푒−10,000푡푡+푚푚2푒푒−40,000푡푡푚푚푡푡≥0The voltage across the induct
    15·1 answer
  • 1. Using a typical frequency value for the initiating event and PFD values provided in class lectures, estimate the mishap or co
    6·1 answer
  • Zionjasean17 zionjasean17
    8·2 answers
  • In contouring, it is necessary to measure position and not velocity for feedback.
    9·1 answer
  • What is the built-in pollution control system in an incinerator called
    6·1 answer
  • 2. When performing an alignment, what action should be taken immediately after putting a vehicle on the rack?
    15·1 answer
  • There are two methods to create simple robots. First, you can construct them by purchasing various individual components and ass
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!