×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Scalar Multiplication of Matrix | Linear Algebra using Python

Linear Algebra using Python | Scalar Multiplication of Matrix: Here, we are going to learn how to find scalar multiplication of matrix in Python?
Submitted by Anuj Singh, on May 20, 2020

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. Matrix is the key to linear algebra. All the linear algebra revolves around matrices. One of the major needed steps in linear algebra is scalar multiplication. When a matrix is defined using NumPy, it's easy to code scalar multiplication.

Python code for Scalar Multiplication of Matrix

# Linear Algebra Learning Sequence
# Scalar Multiplication of a Matrix

import numpy as np

# Use of np.array() to define a matrix
V = np.array([[1,2,3],[2,3,5],[3,6,8]])

# Scalar Multiplication of matrix with c =2
print("The Matrix A =\n",V)
print("The MAtrix 2xA =\n",2*V)

Output:

The Matrix A =
 [[1 2 3]
 [2 3 5]
 [3 6 8]]
The MAtrix 2xA =
 [[ 2  4  6]
 [ 4  6 10]
 [ 6 12 16]]
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.