DeveloperBreeze

Performing Addition and Multiplication on NumPy Arrays

The following Python code demonstrates how to perform element-wise addition of two arrays and scalar multiplication using NumPy:

import numpy as np

# Define two arrays
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])

# Perform element-wise addition
result_addition = arr1 + arr2
print('Addition:', result_addition)

# Perform scalar multiplication
result_multiplication = arr1 * 2
print('Multiplication:', result_multiplication)

Related Posts

More content you might like

Code
python

Generate Fibonacci Sequence

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Sort a List

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Calculate Sum of Numbers in a List Using sum() Function

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Generate List of Even Numbers Using List Comprehension

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!