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
Consider fully developed laminar flow in a circular pipe. If the viscosity of the fluid is reduced by half by heating while the
gladu [14]

Answer:

The pressure drop across the pipe also reduces by half of its initial value if the viscosity of the fluid reduces by half of its original value.

Explanation:

For a fully developed laminar flow in a circular pipe, the flowrate (volumetric) is given by the Hagen-Poiseulle's equation.

Q = π(ΔPR⁴/8μL)

where Q = volumetric flowrate

ΔP = Pressure drop across the pipe

μ = fluid viscosity

L = pipe length

If all the other parameters are kept constant, the pressure drop across the circular pipe is directly proportional to the viscosity of the fluid flowing in the pipe

ΔP = μ(8QL/πR⁴)

ΔP = Kμ

K = (8QL/πR⁴) = constant (for this question)

ΔP = Kμ

K = (ΔP/μ)

So, if the viscosity is halved, the new viscosity (μ₁) will be half of the original viscosity (μ).

μ₁ = (μ/2)

The new pressure drop (ΔP₁) is then

ΔP₁ = Kμ₁ = K(μ/2)

Recall,

K = (ΔP/μ)

ΔP₁ = K(μ/2) = (ΔP/μ) × (μ/2) = (ΔP/2)

Hence, the pressure drop across the pipe also reduces by half of its initial value if the viscosity of the fluid reduces by half of its value.

Hope this Helps!!!

4 0
2 years ago
Now that we have a second enemy, you will need to make some changes to the script that is attached to your backdrop. Look at tha
JulsSmile [24]

Answer:

<u><em>≡</em></u>

Explanation:

8 0
3 years ago
What are the ropes of secretaries and treasures in a meeting​
Nastasia [14]

Answer:

To prepare and issue notices and agendas of all meetings in consultation with the chairman, and to ensure that any background papers are available well before the meeting. To attend and take the minutes of every committee meeting. To circulate minutes to all committee members, and to conduct the correspondence

Explanation:

I think you want to say roles.

4 0
3 years ago
State two faults that are common in a simple cell​
Step2247 [10]

Answer:

the two defects of a simple cell are:

1. Polarization

2. Local action

4 0
2 years ago
Read 2 more answers
A 20-mm-diameter steel bar is to be used as a torsion spring. If the torsional stress in the bar is not to exceed 110 MPa when o
ch4aika [34]

Answer:

1.887 m

Explanation:

(15 *pi)/180

= 0.2618 rad

Polar moment

= Pi*d⁴/32

= (22/7*20⁴)/32

= 15707.96

Torque on shaft

= ((22/7)*20³*110)/16

= 172857.14

= 172.8nm

Shear modulus

G = 79.3

L = Gjθ/T

= 79.3x10⁹x(1.571*10^-8)x0.2618/172.8

= 1.887 m

The length of the bar is therefore 1.887 meters

5 0
3 years ago
Other questions:
  • You are to assess the biomechanics of a male’s arm using his bicep to hold a 20 kg object in his hand. The upper arm is perpendi
    5·1 answer
  • A motor vehicle has a mass of 1.8 tonnes and its wheelbase is 3 m. The centre of gravity of the vehicle is situated in the centr
    14·1 answer
  • WANT POINTS? JUST ANSWER ME:)
    6·2 answers
  • Explain the difference in the heat transfer modes of conduction and convection.
    14·1 answer
  • One of the best ways to find a vacuum leak on a speed-density fuel-injection system is to read the intake air controller (LAC) c
    12·2 answers
  • When a conductor is moved in a magnetic field, a voltage will be induced on the conductor. However, current won't flow through t
    11·1 answer
  • The minimum fresh air requirement of a residential building is specified to be 0.35 air changes per hour (ASHRAE, Standard 62, 1
    10·1 answer
  • What are the important factors needed to be considered while selecting a brake or clutch?
    9·1 answer
  • A Class A fire extingisher is for use on general combustibles such as:​
    14·1 answer
  • A heating element for a cooking appliance is stretched too far during installation. What action can be performed? A. Dispose of
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!