Problem

2/12

Working with vector elements

Theory Click to read/hide

Working with vector elements

Working with vector elements is the same as with list elements, you can access elements by their index, and also make slices.

Example
1
2
3
4
5
6
7
import numpy as np V = np.array((1,2,3,4)) print(V[0]) # 1 print(V[-1]) # 4 print(V[1:-2]) # [2] print(V[::2]) # [1 3]

Problem

The input is a list of numbers (a string where the numbers are separated by a comma).

Create and save:
- into variable V1 Numpy vector of these numbers in the same order;
- to variable V2 Numpy vector containing only penultimate number;
- into a variable V3 Numpy vector of these numbers in reverse order;
- to the variable V4 Numpy a vector of these numbers, starting from 0, through 2 (i.e. every second number);
- to the variable V5 Numpy vector created from the Range generator, containing as many elements as numbers were passed to the input.

Note
You only have to write statements that create the appropriate vectors and store them in the desired variables.
 
Example 
V1 = operator