Plus
Pin


Problem description Progress
ID 37524. Operations with vectors
Темы: numpy   

The input is 2 lists of integers (they are vectors of equal length, i.e. with the same number of elements).

Using vector operations, create and store in a V Numpy variable a vector with the coordinate-wise products of every second number from the first list and every second number from the second list, reversed
Display this vector on the screen.

Examples
# Input Output
1 1 2 3 4
10 20 30 40
[40 60]

ID 37529. Expand Vector
Темы: numpy   

Given a list of integers. 
1. Create a vector from it.
2. "Expand" vector and print it.
 

Examples
# Input Output
1 1 2 3 4 5 6 [6 5 4 3 2 1]

ID 37528. Create a vector
Темы: numpy   

Count 2 numbers:

  • n - Numpy vector size;
  • x - the coordinate of the vector element, which must be equal to 1. The rest of the vector elements must be equal to 0  (\(0 <= x < ;n\)).

Save the vector to the variable V.

Note. You do not need to print anything in this task. Only create vector V.

 
Examples
# Input Output
1 10
4
[0. 0. 0. 0. 1. 0. 0. 0. 0. 0.]

ID 37527. Other Ways to Create Arrays and Matrices
Темы: numpy   

1. Read from the keyboard the number n.
2. In the variable V NumPy , create a vector containing n zeros of type int.

ID 37526. Area of ​​a triangle
Темы: numpy   

A triangle on a plane is given by the coordinates of its vertices. The vertex coordinates are stored as vectors A1, A2, A3. Each vector contains two coordinates of the corresponding vertex (x, y)
Find the area of ​​the triangle.
If all three vertices lie on the same line, then the area is 0.
 

ID 37523. Working with vector elements
Темы: numpy   

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
 

ID 37530. Zero array elements
Темы: numpy   

Given a vector Z

1) Write to the variable NonZerros indices of non-zero elements.
2) Write the  variable Count_NonZerros number of non-zero elements.

Add only 2 lines to the program. You don't need to input or output anything. The vector Z has already been created.

ID 37534. slices
Темы: numpy   

Numbers nrc are given as input. Output an array of size n by n, where r and column c > are 1 and the rest are 0 (use type np.int8).

Example
# Input Output
1 5 1 3 [[0 0 0 1 0]
 [1 1 1 1 1]
 [0 0 0 1 0]
 [0 0 0 1 0]
 [0 0 0 1 0]]

ID 37535. Honorary units
Темы: numpy   

The input is a number n. Print an array of size n by n, in which the lines with even indices contain 1, and the rest — zeros.
 

Examples
# Input Output
1 5 [[1 1 1 1 1]
 [0 0 0 0 0]
 [1 1 1 1 1]
 [0 0 0 0 0]
 [1 1 1 1 1]]

ID 37536. Sieve
Темы: numpy   

Numbers nmrc are given as input. Output an array of size n by m, in which in each r-th line and each c-th column are 0, and the remaining elements are 1.

 

Examples
# Input Output
1 6 7 2 3 [[0 0 0 0 0 0 0]
 [0 1 1 0 1 1 0]
 [0 0 0 0 0 0 0]
 [0 1 1 0 1 1 0]
 [0 0 0 0 0 0 0]
 [0 1 1 0 1 1 0]]

ID 37537. Chess board
Темы: numpy   

The color of a chessboard cell is conditionally encoded by the numbers 1 and 0. Black color - 1, white color - 0. The upper left corner of the board is black. 
For the given number n, display the code table of colors for the chessboard size n by n.

 

Examples
# Input Output
1 4 [[1 0 1 0]
 [0 1 0 1]
 [1 0 1 0]
 [0 1 0 1]]
2 3 [[1 0 1]
 [0 1 0]
 [1 0 1]]

ID 37522. Numpy. Introduction
Темы: numpy   

The input is a list of numbers as a string. Numbers are separated from each other by a comma. Create a vector of these numbers in the same order.

ID 37525. Features of the selection of vector elements
Темы: numpy   

The input is two sets of integers, each in its own line. The numbers are space-separated. Create a vector V that will contain the numbers from the first set divided by the penultimate number from the second set, if the number from the first set is evenly divisible by the penultimate number from the second set.

If there are no such numbers, then the vector V will be empty (that is, it will not contain elements).

 

Examples
# Input Output
1 1 2 
10 10
[]
2 1 2 3 4 5 6
1 2 3 4
[1. 2.]

ID 37531. Diagonal Array
Темы: numpy   

The input is the number n. Output an array of size nxn, in in the diagonal numbers are 0 to n-1, and the rest of the numbers are 0.
 

 

Examples
# Input Output
1 5 [[0 0 0 0 0]
 [0 1 0 0 0]
 [0 0 2 0 0]
 [0 0 0 3 0]
 [0 0 0 0 4]]

ID 37533. Two-dimensional NumPy arrays. Referencing elements
Темы: numpy   

The numbers n and m are given as input. Output an array of size n by m, in which the first line (the line with zero index) contains numbers from 0  up to m-1 and the remaining numbers are 0. The type of array elements must be np.int8.
 

 

Examples
# Input Output
1 3
4
[[0 1 2 3]
 [0 0 0 0]
 [0 0 0 0]]