Question

Should be done in Python, please help Create a class for a 2x2 matrix. Give the...

Should be done in Python, please help

Create a class for a 2x2 matrix. Give the init function and create functions to return each entry of the 2x2 matrix.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

class matrix:

mat = []

def __init__(self,values):

for row in values:

self.mat.append(row)

def getMatrix(self):

return self.mat

#initializing matrix

m = matrix([[1,2],[3,4]])

#return each entry of matrix

print(m.getMatrix())

Add a comment
Know the answer?
Add Answer to:
Should be done in Python, please help Create a class for a 2x2 matrix. Give the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python programming I need help with the following: Create a class Vehicle. The class should have...

    Python programming I need help with the following: Create a class Vehicle. The class should have name, weight, fuel, number of wheels and move attributes/methods. Create child class that are semi, car, sail boat and bicycle. Give the class the ability to have a constructor that sets the name. Have the other attributes hard coded to suit the vehicle. Give each a way of speaking their attributes as well as the type of animal. For example “Hi I am Lightening...

  • The program needs to be in python : First, create a BankAccount class. Your class should...

    The program needs to be in python : First, create a BankAccount class. Your class should support the following methods: class BankAccount (object): """Bank Account protected by a pin number.""" def (self, pin) : init "n"Initial account balance is 0 and pin is 'pin'."" self.balance - 0 self.pin pin def deposit (self, pin, amount): """Increment account balance by amount and return new balance.""" def withdraw (self, pin, amount): """Decrement account balance by amount and return amount withdrawn.""" def get balance...

  • should be done in python please help 9) A file named floats.txt contains a bunch of...

    should be done in python please help 9) A file named floats.txt contains a bunch of numbers. Create a file named stats.txt that contains: the minimum number, the maximum number, the sum of the numbers, the average number, and the standard deviation of the numbers, each on a separate line.

  • PYTHON this implementation is really hard, Im stuck especially with the requirements they give. PLEASE HELP!...

    PYTHON this implementation is really hard, Im stuck especially with the requirements they give. PLEASE HELP! THANK YOU! RECURSIVE! Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define...

  • PYTHON please help! im stuck on this homework question, THANK YOU! please follow the rules! Give...

    PYTHON please help! im stuck on this homework question, THANK YOU! please follow the rules! Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define new functions or helper...

  • Create a Python class called Rectangle. The constructor for this class should take two numeric arguments,...

    Create a Python class called Rectangle. The constructor for this class should take two numeric arguments, width and height. Add a method isEqual that determines if one rectangle is equal to another. Python Please!

  • Should be done in python. Create this list [1, 0.5, 0.33, ... , 0.01]

    Should be done in python. Create this list [1, 0.5, 0.33, ... , 0.01]

  • PLEASE DO THIS IN PYTHON!! Classes/Methods: Kenmore has contacted you to help them create a class...

    PLEASE DO THIS IN PYTHON!! Classes/Methods: Kenmore has contacted you to help them create a class for their newest washing machine. Write the “WashingMachine” class that has the following specifications: Attributes (should be invisible to users): Amount of water (number) Minutes left (the number of minutes left in the cycle) Water level (number indicating how many quarts of water are in the machine CLASS DECLARATION AND ATTRIBUTES ONLY (5 points):

  • Help with Java Program Please Create a simple graph class. The graph class should have the...

    Help with Java Program Please Create a simple graph class. The graph class should have the following items: an adjacency list or matrix to hold the graph data variables to hold the current size and max size of the graph default constructor create empty adjacency list/matrix max size = 10 overloaded constructor create empty adjacency list/matrix max size = int parameter isEmpty check if current size is zero createGraph read a formatted file and fill adjacency list/matrix The first line...

  • Python: Design a Ship class that has the following members: A member variable for the name...

    Python: Design a Ship class that has the following members: A member variable for the name of the ship. A member variable for the year that the ship was built. An init method and appropriate accessors and mutators. A print function that displays the ship’s name and the year it was built. Design a CruiseShip class that is derived from the Ship class. The CruiseShip class should have the following members: A member variable for the maximum number of passengers....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT