Write a python program to find the transpose of a matrix

Assignment Help Python Programming
Reference no: EM132793822

Question 1: Write a Python program to find the transpose of a matrix (i.e, AT), where the column vectors of AT are the row vectors of the original matrix A.

a. Define a function that meets the following specifications:

def TransposeMatrix(AMatrix):

AMatrix is a matrix of dimension m columns by n rows. Note that n≠m generally.

The function should return two values: AT The transpose of AMatrix and a tuple with the ordered pair of (number rows, number cols) of AT.

b. Define a function that meets the following specifications:

def main():
AM=[ [1, -5, 3, -7],
[2, 5, 11, -2],
[13, -1, 0, 4]]

The main function should call the function TransposeMatrix and output to the screen/console the following formatted output:

Transpose of the matrix is:
[[1, 2, 13]
[-5, 5, -1]
[3, 11, 0]
[-7, -2, 4]]
The size of the transpose is: (4 x 3)

Note: Your program should call the function main()when run. We will grade the problem with this exact matrix first and then change the matrix (including its size) to test your program.

Question 2: Stirling's approximation is used to estimate the value of natural logarithms of factorials of large numbers. The mathematical formula is:

a. Write a function that meets the following specifications:

def Stirling(N):

N is a positive integer.

The function should return both the estimated value of ln(N!) and the percent error in the estimation based on the formula: error=1-[nln(n)-n]/ln(N!)

b. Write a function that meets the following specifications:

def main():

Print lines of formatted output to the screen/console in the following format:

ln(500!) = 2605.3 (error = 0.15%)

Notes:
Output a similar formatted line only when error drops below values of 15%, 10%, 5%, 1%
You can calculate the natural logarithm of a function with log()from the math module.
You can calculate the factorial of an integer with factorial() from the math module.

Question 3: A pipe-flow fluids problem:

Oil with a density (ρ=950 kg/m3) and kinematic viscosity (ν=2×10-5m2/s) flows through a 30-cm-diameter (d=0.3m) pipe that is 100 m long with a head loss of hf = 8 m. The roughness ratio of the pipe is (?/d=0.0002) and we can assume the flow is turbulent. Find the average velocity (V) and flow rate (Q=V⋅A) for the oil. g=9.81 m/s2

We can calculate the head loss using the Darcy friction factor as:
where, the friction factor is given by:
where,

a. Write a function def Reynolds(V,nu,d): to calculate Reynolds number
b. Write a function def FrictionFactor(relrough, Re): to calculate the friction factor
c. Write a function def AvgVel(nu, dia, length): to calculate the average velocity of the oil
d. Write a function def main(): to call AvgVel with the appropriate parameters and print to the screen the average oil velocity and volumetric flow rate (with units).
e. Finally, in your main function, determine the diameter of pipe necessary for a head loss of only 6m in a 100m long pipe, keeping viscosity and flow rate constant.

Notes: The velocity V is unknown in parts a., b., and c as are the friction factor and Reynolds numbers. You will likely need to use your secant method to iteratively find the solution. According to the Moody diagram for friction factors, 0.008<f<~0.03 in the turbulent range. F.Y.I., V = 4.84 m/s for part d.

Attachment:- Python program.rar

Reference no: EM132793822

Questions Cloud

What is the implicit interest in dollars in the first year : Purchase a zero coupon bond with a face value of $1,000 maturing in 14 years, for $93,75. What is the implicit interest in dollars in the first year of the bond
Evaluate any innovative managerial practices : Evaluate any innovative managerial practices. What sources of "employee empowerment" are utilized? How is entrepreneurship encouraged?
Calculate the net cash provided by operating activities : Depreciation expense was $17,500 and unrealized losses on FV-NI investments were $4,000. Calculate the net cash provided by operating activities
What is the mission of the organization : What is the mission of the organization? Identify its customers and/or constituents; and its competitors. Define and assess the organization's strategy.
Write a python program to find the transpose of a matrix : Write a Python program to find the transpose of a matrix (i.e, AT), where the column vectors of AT are the row vectors of the original matrix
Determine the net income for the company : Amortization on the truck and office equipment was calculated to be $500. The income tax rate is 10%. Determine the net Income for the company for the month
How much was net income influenced by afs investments year : Assume Cisco purchased all the AFS investments this year. How much was net income influenced by AFS investments this year?
Prepare journal entries to record the foregoing transactions : Investments held by the hospital increased in fair value by $41,000. Prepare journal entries to record the foregoing transactions
What simple rate of return on the new equipment is closest : What simple rate of return on the new equipment is closest to? The equipment would cost $365,000, have a ten-year useful life and a salvage value at the end

Reviews

len2793822

2/10/2021 10:02:53 PM

py file for HW3-5 import math def Stirling(N): Calculates the ln(N!) by Stirling approximation and using math.factorial :param N: An integer (positive) :return: estimate of ln(N!), error in estimate pass def main(): pass main()

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd