HackerRank Python Basic Certification Solutions – FREE SQL Certification

Avatar for Azhar Khan
HackerRank Python Basic Certification
HackerRank Python Basic Certification

Here are the 2 questions asked in HackerRank Python Basic Certification Exam, these 2 will be available in one attempt.

Test duration90 mins
No. Of Questions2 questions
Python Basic Certification Test

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

HackerRank Python Basic Certification - Azhar Khan

Github Repo: https://github.com/adminazhar/HackerRank-Python-Basic-Skills-Certification-Test-Solution

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *


Previous Post
Student Analysis SQL HackerRank Solution

Student Analysis SQL HackerRank Solution

Next Post
Google Gemma

How to Easily Run Google Gemma Model Locally: A Step-by-Step Guide

Related Posts