Coding L4: -
1. What are arrays in programming?
Arrays are collection of similar data type variables. Array can store multiples values which
can be referenced by single name. Arrays are always stores in specific memory location.
Arrays do not support different data types in same collection.
2. Explain how arrays are indexed in programming.
The variables in an Array are always ordered sequentially with index starting with 0.
Example: Array with variables of Integer Data Type stored in it.
Here, Length of Array = 6
First Index = 0
Last Index = 5
3. Explain how you can sort an array {67, 23, 98, 19} using Python?
Sorting is the process of ordering items in a collection. Python has inbuilt sort function to
order an array. The sort () method sorts the list ascending by default.
Numbers = [67, 23, 98, 19]
Numbers Sort ()
Print (Numbers)
Output: [19, 23, 67, 98]
4. How do you search a particular value from an array in Python?
Python uses indexing as a method to search for an element in an array. For Example –
X = [34,45,3,23,22,78,65]
Print(X.index(23))
If you run the above code, you would get 3 as output. As 23 is located on index 3.