# Month: March 2021

## Python Example – Write a NumPy program to compute the inner product of vectors for 1-D array

(Python Example for Beginners)   Write a NumPy program to compute the inner product of vectors for 1-D arrays (without complex conjugation) and in higher dimension.   Sample Solution : Python Code : import numpy as np a = np.array([1,2,5]) b = np.array([2,1,0]) print(“Original 1-d arrays:”) print(a) print(b) print result = np.inner(a, b) print(“Inner product of …

## Python Example – Write a NumPy program to evaluate Einstein’s summation convention of two given multidimensional arrays

(Python Example for Beginners)   Write a NumPy program to evaluate Einstein’s summation convention of two given multidimensional arrays. Note: In mathematics, especially in applications of linear algebra to physics, the Einstein notation or Einstein summation convention is a notational convention that implies summation over a set of indexed terms in a formula, thus achieving …

## Python Example – Write a NumPy program to compute the outer product of two given vectors

(Python Example for Beginners)   Write a NumPy program to compute the outer product of two given vectors.   Sample Solution : Python Code : import numpy as np p = [[1, 0], [0, 1]] q = [[1, 2], [3, 4]] print(“original matrix:”) print(p) print(q) result = np.outer(p, q) print(“Outer product of the said two vectors:”) …

## Python Example – Write a NumPy program to compute the multiplication of two given matrixes

(Python Example for Beginners)   Write a NumPy program to compute the multiplication of two given matrixes. Sample Matrix: [[1, 0], [0, 1]] [[1, 2], [3, 4]]   Sample Solution : Python Code : import numpy as np p = [[1, 0], [0, 1]] q = [[1, 2], [3, 4]] print(“original matrix:”) print(p) print(q) result1 = …

## Python Example – Write a NumPy program to convert a list of numeric value into a one-dimensional NumPy array

(Python Example for Beginners)   Write a NumPy program to convert a list of numeric value into a one-dimensional NumPy array. Sample Solution: Python Code: import numpy as np l = [12.23, 13.32, 100, 36.32] print(“Original List:”,l) a = np.array(l) print(“One-dimensional NumPy array: “,a) Sample Output: Original List: [12.23, 13.32, 100, 36.32] One-dimensional NumPy array: …

## Python Example – Write a Python program to find a missing number from a list

(Python Example for Beginners)   Write a Python program to find a missing number from a list.   Sample Solution: Python Code: def missing_number(num_list): return sum(range(num_list,num_list[-1]+1)) – sum(num_list) print(missing_number([1,2,3,4,6,7,8])) print(missing_number([10,11,12,14,15,16,17])) Sample Output: 5 13   Python Example – Write a Python program to find a missing number from a list Free Machine Learning & Data …

## Python Example – Write a Python program to check if an integer is the power of another integer

(Python Example for Beginners)   Write a Python program to check if an integer is the power of another integer.   Sample Solution: Python Code: def is_Power(x, y): while (x%y == 0): x = x / y return x == 1 print(is_Power(16, 2)) print(is_Power(12, 2)) print(is_Power(81, 3)) Sample Output: True False True   Python Example …

## Python Example – Write a Python program to check if a given positive integer is a power of two

(Python Example for Beginners)   Write a Python program to check if a given positive integer is a power of two.   Sample Solution: Python Code: def is_Power_of_two(n): return n > 0 and (n & (n – 1)) == 0 print(is_Power_of_two(4)) print(is_Power_of_two(36)) print(is_Power_of_two(16)) Sample Output: True False True   Python Example – Write a Python …

## Java tutorials for Beginners – Java ObjectInputStream Class

(Java programming Example for Beginners) Java ObjectInputStream Class In this tutorial, we will learn about Java ObjectOutputStream and its methods with the help of examples. The ObjectInputStream class of the java.io package can be used to read objects that were previously written by ObjectOutputStream. It extends the InputStream abstract class. Before you learn about the ObjectInputStream class, make sure you know about the ObjectOutputStream Class. …

## Java tutorials for Beginners – Java ByteArrayInputStream Class

(Java programming Example for Beginners) Java ByteArrayInputStream Class In this tutorial, we will learn about Java ByteArrayInputStream and its methods with the help of examples. The ByteArrayInputStream class of the java.io package can be used to read an array of input data (in bytes). It extends the InputStream abstract class. Note: In ByteArrayInputStream, the input stream is created using the array of …

## Java tutorials for Beginners – Java FileInputStream Class

(Java programming Example for Beginners) Java FileInputStream Class In this tutorial, we will learn about Java FileInputStream and its methods with the help of examples. The FileInputStream class of the java.io package can be used to read data (in bytes) from files. It extends the InputStream abstract class. Before we learn about FileInputStream, make sure to know about Java Files. Create a FileInputStream …

## Python Example – Write a Python program to create a Pythagorean theorem calculator

(Python Example for Beginners)   Write a Python program to create a Pythagorean theorem calculator. Note : In mathematics, the Pythagorean theorem, also known as Pythagoras’ theorem, is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the square of the hypotenuse (the side opposite the right …