Skip to content
CampusEduX

Problem 4: Compare Two Arrays Element-Wise

Easypython
Learn the Concept: NumPy

Problem Description

Write a Python program that takes two NumPy arrays of the same length and prints a new array showing True where elements in the first array are greater than the corresponding elements in the second array, and False otherwise.

Input

Two lists of numbers, of equal length.

Output

A NumPy array of True/False values based on the element-wise comparison.

Constraints

  • Both lists will have the same number of elements.

Example Input

text
array1 = [10, 20, 5, 40], array2 = [8, 25, 5, 30]

Example Output

text
[ True False False True]

Concepts Covered

NumPy arrays, element-wise comparison, boolean arrays.

Related Problems

  • Problem 1: Array Statistics Calculator
    Easy · python
    Solve Problem
  • Problem 2: Add Bonus Marks Using Vectorization
    Easy · python
    Solve Problem
  • Problem 3: Reshape a 1D Array into a 2D Grid
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...