﻿ Python: Create an array of 5 integers and display the array items - w3resource # Python: Create an array of 5 integers and display the array items

## Python: Array Exercise-1 with Solution

Write a Python program to create an array of 5 integers and display the array items. Access individual element through indexes.

Pictorial Presentation: Sample Solution:

Python Code :

``````from array import *
array_num = array('i', [1,3,5,7,9])
for i in array_num:
print(i)
print("Access first three items individually")
print(array_num)
print(array_num)
print(array_num)
``````

Sample Output:

```1
3
5
7
9
Access first three items individually
1
3
5
```

Python Code Editor:

Previous: Python Array Exercise Home.
Next: Write a Python program to append a new item to the end of the array.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Python: Unpack a Tuple

```>>> items = (0, 'b', 'one', 10,  11, 'zero')
>>> a, b, c, d, e, f = items
>>> print(f)
zero
>>> a, *b, c = items
>>> print(b)
['b', 'one', 10, 11]
>>> *_, a, b = items
>>> print(a)
11
```