HackerRank Python Solution - Math Topic - Integer Come In All Sizes

  • Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: 231-1 (c++ int) or 263-1 (C++ long long int).
  • As we know, the result of ab grows really fast with increasing b.
  • Let's do some calculations on very large integers.

HackerRank Python Solution - Math Topic - Power - Mod Power

  • So far, we have only heard of Python's powers. Now, we will witness them!
  • Powers or exponents in Python can be calculated using the built-in power function. Call the power function ab as shown below:
>>> pow(a,b) 
or
 
>>> a**b
It's also possible to calculate ab mod m.
 
>>> pow(a,b,m)  

HackerRank Python Solution - Math Topic - Mod Divmod

One of the built-in functions of Python is divmod, which takes two arguments a and b, and returns a tuple containing the quotient of a/b first and then the remainder a.

For example:
 
>>> print divmod(177,10)
(17, 7)
Here, the integer division is 177/10 => 17 and the modulo operator is 177%10 => 7.

HackerRank Python Solution - Math Topic - Triangle Quest 2

  • You are given a positive integer N.
  • Your task is to print a palindromic triangle of size N.
  • For example, a palindromic triangle of size 5 is:
1
121
12321
1234321
123454321
  • You can't take more than two lines. The first line (a for-statement) is already written for you.
  • You have to complete the code using exactly one print statement. 

HackerRank Python Solution - Math Topic - Find Angle MBC

  • ABC is a right triangle, 90˙ at B. Therefore ∡ABC = 90˙
HackerRank Python Solution - Math Topic - Find Angle MBC
  • Point M is the midpoint of hypotenuse AC.
  • You are given the lengths AB and BC.
  • Your task is to find ∡MBC (angle Ө˙, as shown in the figure) in degrees.
Input Format:
  • The first line contains the length of side AB.
  • The second line contains the length of side BC.

You might also like

Deploy your Django web app to Azure Web App using App Service - F1 free plan

In this post, we will look at how we can deploy our Django app using the Microsoft Azure app service - a free plan. You need an Azure accoun...