✅ Line-by-line Explanation:
import array as arr
This imports Python’s built-in array module and gives it the alias arr for easier use.
c = arr.array('f', [1.1, 2.2, 3.3])
-
This creates an array named c.
'f' is the type code for floating-point numbers (4 bytes, like float in C).
[1.1, 2.2, 3.3] is a list of float values that will be stored in the array.
So c is now an array like:
print(c[1])
-
This prints the element at index 1 of the array c.
-
Python arrays are zero-indexed, so:
c[0] → 1.1
c[1] → 2.2
c[2] → 3.3
✅ Output:
Summary:
This code creates a float array using the array module and prints the second value in the array, which is 2.2.


0 Comments:
Post a Comment