Here's a line-by-line explanation of this code:
✅ This imports the array class from Python's built-in array module.
The array module allows you to create an array that stores only one type of data (like integers, floats, etc.).
✅ This creates an array a of type 'i' (which stands for signed integers).
It contains 3 integer elements: [10, 20, 30].
So now:
✅ This is a for loop that iterates over each element in the array a.
-
First, i = 10, it prints 10
-
Then, i = 20, it prints 20
-
Then, i = 30, it prints 30
The end=' ' part tells Python to print the values on the same line, separated by a space instead of printing each on a new line.
✅ Final Output:


0 Comments:
Post a Comment