×

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

Python | Constant Matrix

Python | Constant Matrix: In this tutorial, we are going to learn about the constant matrix and its Python implementation.
Submitted by Anuj Singh, on July 09, 2020

In this article, we are going to create a constant matrix, where all the elements of the matrix have the same constant value. This can be done by online inbuilt function numpy.full(). This NumPy library function returns a constant matrix.

Python code to create constant matrix

# Linear Algebra Learning Sequence
# Constant Matrix

import numpy as np

M = np.full((5,6), 44)

print('A constant matrix with all entries as 44 :\n', M)

Output:

A constant matrix with all entries as 44 :
 [[44 44 44 44 44 44]
 [44 44 44 44 44 44]
 [44 44 44 44 44 44]
 [44 44 44 44 44 44]
 [44 44 44 44 44 44]]
 
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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