Here are the 2 questions asked in HackerRank Python Basic Certification Exam, these 2 will be available in one attempt.
Test duration | 90 mins |
No. Of Questions | 2 questions |
Shape Classes with Area Method Python Solution
class Rectangle:
def __init__(self,breadth,length):
self.breadth=breadth
self.length=length
def area(self):
return self.breadth*self.length
pass
class Circle:
def __init__(self,radius):
self.radius=radius
def area(self):
return math.pi*(self.radius**2)
pass
Dominant Cells Python Solution
def numCells(grid):
# Write your code here
res = 0
for i in range(len(grid)):
for k in range (len(grid[0])):
val = grid[i][k]
flag = 1
for ii in range (max(0,i-1),min(len(grid),i+2)):
for kk in range(max(0,k-1),min(len(grid[0]),k+2)):
if (ii,kk)!=(i,k) and val<= grid[ii][kk] :
flag=0
break
if flag == 0:
break
else:
res+=1
return res
The solution of HackerRank Python Basic Certification problem shape classes with area method and dominant cells is shared for your increasing knowledge. Please don’t copy the code. You can use the code to make your understanding clear.
I have taken HackerRank Python (Basic) Skills Certification Test on 8th April 2023. Certificate can be viewed here
Github Repo: https://github.com/adminazhar/HackerRank-Python-Basic-Skills-Certification-Test-Solution