How to Create a 3X3 Identity Matrix in Python | Previously we have developed programs to create a matrix in Python now, we will discuss how to create a 3×3 identity matrix in Python. Matrix is a rectangular table arranged in the form of rows and columns, in the programming world we implement matrix by using arrays by classifying it as 1D and 2D arrays. In this section, there are some examples to create a 3×3 identity matrix in python.
How to Create a 3X3 Identity Matrix in Python
A 3X3 matrix is a matrix that has 3 rows and 3 columns, and an identity matrix is a matrix whose diagonal elements are always 1. The function np.identity() itself creates an identity matrix of 3 rows and 3 columns.
import numpy as np
m = np.identity(3)
print(m)
Output:
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
Python Program Examples
- Subtract Lists in Python
- Average of Numbers in List
- Remove item from List in Python
- Remove the First Element from List
- Remove the Last Element from List
- Delete all Elements in List
- Check for Duplicates in List
- Find Duplicates in List in Python
- Remove Special Characters From list
- Remove Duplicates from List in Python
Python Programs for Searching
Python String Programs
- Convert ASCII to String
- Convert String to ASCII
- List of Alphabets Python
- Check Special Character
- Print Alphabets in Python
- Concatenate String and int
- Palindrome String in Python
- How to Swap case in Python
- Check Two Strings are equal
- Capitalize First Letter in Python
- Print Vowels in a String in Python
- Print Consonants in a String in Python
- Print Vowels and Consonants in a String
- Separate Vowels and Consonants in a String
- Find Vowels in String in String
- Count Vowels in a String in Python
- Find Consonants in String in Python
- Count Consonants in a String in Python
- Find Vowels and Consonants in a String
- Check if String Contains Vowels
- Check if String Starts with Vowel
- Remove Vowels from String in Python
- Get the First Character of String
- Get the Last Character of String
- Get First N Characters of String
- Extract Numbers From String
- Remove Character from String
- Remove First Character from String
- Remove Last Character from String
- Remove Special Characters from String
- Convert Hex String to ASCII String
- Compute Sum of Digits in a String
- Compare Strings with Ignore-case
- Convert Uppercase to Lowercase
- Convert Lowercase to Uppercase
- Count Uppercase and Lowercase
- Print only Uppercase letters of String
- Reverse a String in Python
- Reverse a String in Python using For Loop
- Reverse a String in Python using While Loop
- Reverse a String in Python using Function
- Reverse a String in Python using Recursion