Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import biblioteki numpy
- import numpy
- # Przeliczanie grady na radiany
- def grads_to_radians(grads):
- if isinstance(grads, list):
- radians = []
- for grad in grads:
- radians.append((grad * numpy.pi) / 200)
- return radians
- else:
- return (grads * numpy.pi) / 200
- # Przeliczanie radianów na grady
- def radians_to_grads(radians):
- if isinstance(radians, list):
- grads = []
- for radian in radians:
- grads.append((radian * 200) / numpy.pi)
- return grads
- else:
- return (radians * 200) / numpy.pi
- # Tablice z wartościami macierzy
- # A = [1, 2, 5, 8]
- # [4, -5, 9, 7]
- # [1, 0, 0, 2]
- # [3, 6, 7, 2]
- #
- # B = [2, 4]
- # [2, 3]
- # [5, 6]
- # [1, 2]
- A = numpy.array([[1, 2, 5, 8], [4, -5, 9, 7], [1, 0, 0, 2], [3, 6, 7, 2]])
- B = numpy.array([[2, 4], [2, 3], [5, 6], [1, 2]])
- # Zadanie 1
- print("## Zadanie nr 1 ##")
- print("Grady -> Radiany")
- print(grads_to_radians(100))
- print(grads_to_radians([100, 50, 20]))
- print("#########################\n\n")
- # Zadanie 2
- print("## Zadanie nr 2 ##")
- print("Grady -> Radiany")
- print(radians_to_grads(100))
- print(radians_to_grads([100, 50, 20]))
- print("#########################\n\n")
- # Zadanie 3
- print("## Zadanie nr 3 ##")
- print("Mnożenie macierzy:")
- print(A.dot(B))
- print("\n")
- print("Macierz transponowana:")
- print(A.T)
- print("\n")
- print("Macierz odwrotna:")
- print(numpy.linalg.inv(A))
- print("#########################")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement