Problem - Linear Algebra using Numpy Hackerrank














































Problem - Linear Algebra using Numpy Hackerrank



Hello, Rishabh here, this time I bring to you:


Linear Algebra using Numpy


Task1

You are given a square matrix with dimensions X. Your task is to find the determinant.
Note: Round the answer to 2 places after the decimal.

Input Format

The first line contains the integer .

The next  lines contains the  space separated elements of array .

Output Format

Print the determinant of .

Sample Input

2

1.1 1.1

1.1 1.1


Sample Output

0.0


Code

1
2
3
4
5
import numpy as np
N = int(input())
A = np.array([input().split() for i in range(N)],float)
#Determinant_
print(np.linalg.det(A))

Task2

You are given a 2-D array of size X.
Your task is to find:

1.       The mean along axis 

2.       The var along axis 

3.      The std along axis 


Input Format

The first line contains the space separated values of  and .
The next  lines contains  space separated integers.


Output Format

First, print the mean.
Second, print the 
var.
Third, print the 
std.


Sample Input

2 2

1 2

3 4


Sample Output

[ 1.5  3.5]

[ 1.  1.]

1.11803398875


Code

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
import numpy as np 

n,m = map(int, input().split())
b = []
for i in range(n):
a = list(map(int, input().split()))
b.append(a)

b = np.array(b)

np.set_printoptions(legacy='1.13')
print(np.mean(b, axis = 1))
print(np.var(b, axis = 0))
print(np.std(b))


End.

Please comment below any questions or article requests.
Like the articles and Follow me to get notified when I post another article.
Cheers!



More Articles of Rishabh Karmakar:

Name Views Likes
Basic Date and Time in Python 165 1
Using Defaultdict in Python 55 1
Floor Division in Python 204 1
Python time sleep function 77 1
Immutable Objects in Python 78 1
Mutable Objects in Python 81 1
Python Escape Sequences 70 1
Escape Sequence in Python 0 0
Python Bytearray 65 1
Plotting Histogram in Python 138 1
Using Voluptuous in Python 173 1
TRAINING MACHINE LEARNING MODEL WITH TENSORFLOW CLOUD 257 1
Pandas - ModuleNotFoundError - No Module Named Pandas and Functions Explained 5477 5
OpenCV - ModuleNotFoundError - No Module Named cv2 and Algorithms Explained 344 5
OpenCV - ModuleNotFoundError - No Module Named 274 9
Simple Python Project Mario Shooter Game 389 4
Web crawling using Python and Scrapy 266 6
CNN vs ANN vs RNN 294 6
Deep Learning - Activation and Loss Function 249 6
CNN vs. RNN vs. ANN 42 10
Advanced Python Projects Predicting and Forecasting Stock Market Prices 562 6
Intermediate Python Projects Tensorflow Live Object Detection 329 7
Intermediate Python Projects Optical Character and Text Recognizer from Live Images 336 7
Advanced Python Projects Analysing Music Trends and Recommendations 468 7
Advanced Python Projects Python Chatbot using NLTK and Keras 760 7
Advanced Python Projects CIFAR-10 Image Classification using Deep Learning 554 9
Advanced Python Projects Image Caption Generator using CNN and LSTM 454 10
Advanced Python Project Breast Cancer Classification using SVR 373 10
Advanced Python Project Smiling Face Detector using CNN 445 10
Advanced Python Project Handwritten Digit Recognizer 506 11
Intermediate Python Project Speed Typing in Python 456 10
Advanced Python Project Next Alphabet or Word Prediction using LSTM 365 12
Intermediate Python Project Find most similar word using Word2Vec 288 10
Advanced Python Projects IMDB Movie Review Sentiment Analysis 261 10
Intermediate Python Project Detection of Real or Fake News 282 10
Advanced Python Project Credit Card Fraud Detection 264 10
Intermediate Python Project Snake Game Pygame 326 10
Simple Python Projects Make a multi-colored rainbow pattern in Python 400 10
Advanced Project Analysis with Sentiment Classification using Bidirectional Recurrent Neural Network 244 10
Advanced Project Forest Fire Prediction using SVR Random Forest and Deep NN 380 10
Advanced Project Sentiment and WordCloud Analysis of Online Reviews 337 12
Python - Synthetic Data Generator for Machine Learning and Artificial Intelligence 263 9
Advanced Project Deep Dream AI 269 10
Python - Symbolic regression classification generator 271 9
Generate Polynomial Functions and Random Function Generator - Python 286 10
Intermediate Project Sentiment and WordCloud Analysis of Women E-Commerce 287 10
Intermediate Project Iris Data Classification 226 10
Intermediate Project Titanic Classification using Decision Tree 248 10
Machine Learning - Decision Tree in Python 296 9
Python - All about lambda functions 251 9
Machine Learning - Polynomial Regression in Python 278 9
Machine Learning - Multiple Linear Regression in Python 260 11
Machine Learning - Simple Linear Regression in Python 244 9
Implement all 2D and 3D types plots in Python 236 9
Implement 1D, 2D and 3D CNN in Python 310 9
Simple Python Projects Multiplayer Tic-Tac-Toe 273 11
Problem - Validating Credit Card Numbers Hackerrank 276 9
Problem - Linear Algebra using Numpy Hackerrank 713 9
Problem - Basic Spell Checker Hackerrank 214 9
Implement Binary Tree in Python 277 9
Implement Graph in Python 262 9
Python for Data Science 213 9
Simple Python Projects Select Region of Interest - OpenCV 324 10
Simple Python Projects Code to mask white pixels in a coloured image - OpenCV 336 10
Simple Python Projects Code to mask white pixels in a gray scale image - OpenCV 297 10
Simple Python Projects Convert colour image to gray scale and apply cartoon effects - OpenCV 347 10
Advanced Project - Automatic Facial Recognition Based Attendance System 718 9
Simple Python Projects Live Talking Counting Clock - Pyttsx3, Tkinter 263 10
Python Simple and Fast Text to Speech 228 9
Simple Python Projects Simple Zodiac Sign Teller 233 10
Simple Python Projects Simple Fortune Teller Game 275 10
Simple Python Projects Simple Guessing Game 390 10
Implementing Multi-line Strings 202 9
Save and Load Machine Learning Models in Python with scikit-learn 399 9
Use of Ternary operator for conditional assignment. 350 9
Chaining comparison operators 215 9
Implement Circular Singly Linked List 241 9
Implementing Command Line Arguments 356 9
Solve Knapsack Problem Using Dynamic Programming 386 10

Comments