Skip to content

Nayan-2006-opensource/2-D-Matrix-data-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

🧮 Matrix Operations using Python OOP

A simple Python project that implements 2×2 matrix operations using Object-Oriented Programming (OOP) and operator overloading (magic methods).

✨ Features

  • ➕ Matrix Addition
  • ➖ Matrix Subtraction
  • ✖️ Matrix Multiplication
  • 🧩 Clean matrix output formatting
  • 🐍 Uses Python magic methods (__add__, __sub__, __mul__, __str__)

📂 Project Structure

matrix.py

🚀 Example

Input

x = Matrix(1,2,3,4)
y = Matrix(4,7,8,9)

print(x)
print(y)

print(x + y)
print(x - y)
print(x * y)

Output

[1 2]
[3 4]

[4 7]
[8 9]

Addition:
[5 9]
[11 13]

Subtraction:
[-3 -5]
[-5 -5]

Multiplication:
[20 25]
[44 57]

📖 Concepts Used

  • Object-Oriented Programming (OOP)
  • Classes & Objects
  • Constructor (__init__)
  • Magic Methods
  • Operator Overloading
  • Matrix Arithmetic

🛠️ Future Improvements

  • Support matrices of any size (NxN)
  • Matrix transpose
  • Determinant calculation
  • Matrix inverse
  • Scalar multiplication
  • Input matrices from the user
  • Error handling for invalid dimensions

👨‍💻 Author

Nayan Samadhiya

GitHub: https://github.com/Nayan-2006-opensource

About

Python implementation of 2×2 matrix operations with object-oriented programming and magic methods.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages