HackerRank Python Solution - Built-Ins - Input()

input():
  • In Python, the expression input() is equivalent to eval(raw _input(prompt)).
Code:
 
>>> input()  
1+2
3
>>> company = 'HackerRank'
>>> website = 'www.hackerrank.com'
>>> input()
'The company name: '+company+' and website: '+website
'The company name: HackerRank and website: www.hackerrank.com'

HackerRank Python Solution - Built-Ins - Zipped!

Zip([iterable, ...]):
  • This function returns a list of tuples. The ith tuple contains the ith element from each of the argument sequences or iterables.
  • If the argument sequences are of unequal lengths, then the returned list is truncated to the length of the shortest argument sequence.
Sample Code:

>>> print zip([1,2,3,4,5,6],'Hacker')
[(1, 'H'), (2, 'a'), (3, 'c'), (4, 'k'), (5, 'e'), (6, 'r')]
>>> 
>>> print zip([1,2,3,4,5,6],[0,9,8,7,6,5,4,3,2,1])
[(1, 0), (2, 9), (3, 8), (4, 7), (5, 6), (6, 5)]
>>> 
>>> A = [1,2,3]
>>> B = [6,5,4]
>>> C = [7,8,9]
>>> X = [A] + [B] + [C]
>>> 
>>> print zip(*X)
[(1, 6, 7), (2, 5, 8), (3, 4, 9)]

Microsoft Azure Fundamentals AZ-900 Exam Practice Test

Microsoft Azure Fundamental AZ-900 Topic:

  • Describe Cloud Concepts (20-25%)
  • Describe Core Azure Services (15-20%)
  • Describe core solutions and management tools on Azure (10-15%)
  • Describe general security and network security features (10-15%)
  • Describe identity, governance, privacy, and compliance features (15-20%)
  • Describe Azure cost management and Service Level Agreements (10-15%)
48 questions | 70% correct required to PASS

HackerRank Python Solution - Sets - No Idea!

There is an array of n integers. There are also 2 disjoint sets, A and B, each containing m integers. You like all the integers in set A and dislike all the integers in set B. Your initial happiness is 0. For each i integer in the array, if i ∊ A, you add 1 to your happiness. If i ∊ B, you add -1 to your happiness. Otherwise, your happiness does not change. Output your final happiness at the end.

Note: Since A and B are set, they have no repeated elements. However, the array might contain duplicate elements.

HackerRank Python Solution - Sets - Check Strict Superset

  • You are given a set A and n other sets.
  • Your job is to find whether set A is a strict superset of each of the N sets.
  • Print True, if A is a strict superset of each of the N sets. Otherwise, print False.
  • A strict superset has at least one element that does not exist in its subset.

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...