Skip to content

AndriiNorets/numpy_examples

Repository files navigation

Numpy examples

In this repository there are examples of work with numpy library in python language.

TASK 1

Using the arange function, create a Numpy array of 20 consecutive multiples of the number 2.


TASK 2

Create a list consisting of floating point values and then write a copy of the list converted to int64 type to the variable.

Display the new list and note what happens to the decimal values.


TASK 3

Write a function that will:

  • take one parametern in integer form
  • return a Numpy array of size n*n consecutive integers starting from1 The number n is to be given by the user.Display the array and the size of the created array

TASK 4

Write a function that will take 2 parameters:a number,

  • which will be the basis for the operation of the power and the number of consecutive powers to generate. Using the logspace function generate a one-dimensional array of consecutive powers of the given number, e.g.generate(2,4) -> [2 4 8 16]

TASK 5

Write a function that:

  • on the input it takes one parameter specifying the length of the vector,
  • on the basis of the parameter generates a vector, but in reverse order(that is, for example, for n=3=>[3 2 1])
  • generates a diagonal matrix with the aforementioned vector as a diagonal

TASK 6

  • Create a script that outputs a numpy array(multidimensional array) in the form of a plot, where one word will be written in a column, one in a row and one diagonally.One of these words should be written from right to left.

TASK 7

Write a function that generates a multidimensional matrix of the form:

 [[2 4 6]
  [4 2 4]
  [6 4 2]]

Under the assumptions:

  • the function takes a parameter n,which specifies the dimensions of the matrix as n*n and places multiples of 2 on its successive diagonals diverging from the main diagonal.

TASK 8

Write a function that:

  • as an input parameter will take a numpy multidimensional array and the direction parameter
  • the direction parameter determines whether the input array will be split vertically or horizontally(the default is to split horizontally)
  • function divides the input array in half

(write a condition that will display a message that the number of rows or columns, depending on the direction of division, does not allow the operation)


TASK 9

  • Use the functions of the Numpy library learned in class and create an array5x5, which will contain successive values of the Fibonacci sequence

TASK 10

  • Create a matrix of2x3 different values and then calculate the sin for each of its values and save to variable a
  • Create a new matrix of 2x3 different values and then calculate the cos for each of its values and save to the variable b
  • Execute the addition function of both matrices previously saved to the variables a and b.

TASK 11 Generate a 3x3 matrix and then:

  • display each row in a loop
  • display each element in the loop

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages