Write a Python program to find the largest number in a NumPy array

SOLUTION.

import numpy as np

# Taking dynamic input for array size
n = int(input("Enter the number of elements in the array: "))

# Taking dynamic input for array elements
arr = np.array([float(input(f"Enter element {i+1}: ")) for i in range(n)])

# Finding the largest number
largest = np.max(arr)

# Displaying the result
print("The largest number in the array is:", largest)
    

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.