Write a program that takes two arrays of integers and checks if they are equal (have the same elements in the same order).
from array import array
# Function to check if two arrays are equal
def are_arrays_equal(array1, array2):
return array1 == array2
# Take two arrays of integers as input
array1 = array('i', [int(x) for x in input("Enter elements for Array 1: ").split()])
array2 = array('i', [int(x) for x in input("Enter elements for Array 2: ").split()])
# Check if the arrays are equal
if are_arrays_equal(array1, array2):
print("The arrays are equal.")
else:
print("The arrays are not equal.")
In this program:
The user is prompted to enter elements for both array1 and array2.
The function are_arrays_equal compares the two arrays using the == operator.
The program checks if the arrays are equal and prints the corresponding message.
Inter Board Karachi Guess/Model Papers 2023 Board Karachi Model Papers 2023 Computer's Guess Paper 9th Class 2023 Computer's Guess Paper 9th Class 2026 Computer's Guess Paper 10th Class 2023 Computer's Guess Paper 11th Class 2023 Computer's Guess Paper 12th Class 2023 Prepared By Sir Rana Arsalan Inter Part-I Model Papers Inter Part-II Model Papers Model Paper Mathematics I Model Paper Mathematics II Model Paper Islamiat Model Paper Urdu II Model Paper Urdu I Model Paper Pakistan Studies Model Paper Botany I Model Paper Botany II Model Paper Chem I — MCQs Model Paper Chem II — MCQs Model Paper Physics I Model Paper Physics II Model Paper Zoology I Model Paper Zoology II Model Paper English I Model Paper English II
Comments
Post a Comment
If you have any doubts, Please let me know .