Python Array Solution Q2

 Create an array of 10 integers. Find and print the maximum and minimum values in the array.


solve

from array import array

# Create an array of 10 integers

int_array = array('i', [5, 8, 2, 10, 15, 7, 3, 12, 1, 9])


# Find and print the maximum and minimum values

max_value = max(int_array)

min_value = min(int_array)


print(f"The maximum value in the array is: {max_value}")

print(f"The minimum value in the array is: {min_value}")


In this program:


We import the array module.

An array of integers ('i' typecode) is created with 10 predefined values.

The max() and min() functions are used to find the maximum and minimum values in the array.

The results are printed.

You can modify the values in the array to test the program with different sets of integers

Comments

Popular posts from this blog

Inter Board Karachi Guess/Model Papers 2023 (1st year & 2nd year)

Class X Test / Model Paper Chapter No 1 Computer

Dulla Bhatti Real Hero Of Muslims Rajput