[HackerRank][30 Days of Code] Day 4: Class vs. Instance
·
🚩 Coding Test/HackerRank
[Problem] https://www.hackerrank.com/challenges/30-class-vs-instance/problem?isFullScreen=true Day 4: Class vs. Instance | HackerRank Learn the difference between class variables and instance variables. www.hackerrank.com [Code] class Person: def __init__(self,initialAge): # Add some more code to run some checks on initialAge if initialAge < 0: print("Age is not valid, setting age to 0.") self.a..
[HackerRank][Numpy] Sum and Prod
·
🚩 Coding Test/HackerRank
[Problem] https://www.hackerrank.com/challenges/np-sum-and-prod/problem?isFullScreen=true Sum and Prod | HackerRank Perform the sum and prod functions of NumPy on the given 2-D array. www.hackerrank.com [Learn] Sum import numpy my_array = numpy.array([ [1, 2], [3, 4] ]) print numpy.sum(my_array, axis = 0) #Output : [4 6] print numpy.sum(my_array, axis = 1) #Output : [3 7] print numpy.sum(my_arra..