CodeChef - Python Practice Solution - Burgers

Problem:
  • The chef is fond of burgers and decided to make as many as possible.
  • The chef has A patties and B buns. To make 11 burgers, Chef needs 11 patties and 11 buns.
  • Find the maximum number of burgers that the Chef can make.

CodeChef - Python Practice Solution - Age Limit

Problem:
  • Chef wants to appear in a competitive exam. To take the exam, there are the following requirements:
    • The minimum age limit is X (i.e. Age should be greater than or equal to X).
    • Age should be strictly less than Y.
  • The chef's current Age is A. Find whether he is currently eligible to take the exam or not.

HackerRank Python Solution - Regex and Parsing - Re.split()

  • You are given a string s consisting only of digits 0-9, commas ,, and dots .
  • Your task is to complete the regex_pattern defined below, which will be used to re.split() all of the , and . symbols in s.
  • Every comma and every dot in s is guaranteed to be preceded and followed by a digit.
Sample Input:

100,000,000.000

HackerRank Python Solution - Regex and Parsing - Detect Floating Point Number

  • You are given a string N.
  • Your task is to verify that N is a floating-point number. 
  • In this task, a valid float number must satisfy all of the following requirements:
    • Number can start with +, - or . symbol.
    • For example: 
      • ✔+4.50
      • ✔-1.0
      • ✔.5
      • ✔-.7
      • ✔+.4
      • ✖-+4.5
    • Number must contain at least 1 decimal value.

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 account, Visual Studio Code editor, and your developed Django App to follow the below steps. If you don't have an Azure account, you can create a free account by going to this URL Microsoft Azure

I have developed a simple web app using Django, which renders an HTML page to explain this topic. If you have a dependency on databases like Postgres or Azure storage, those also need to be configured. 

Create a Web App in Azure:

Let's first start with setting up the app service plan in Azure.

HackerRank Python Solution - Debugging - Default Arguments

  • Python supports a useful concept of default argument values. For each keyword argument of a function, we can assign a default value which is going to be used as the value of said argument if the function is called without it. For example, consider the following increment function:
def increment_by(n, increment=1):
    return n + increment
  • The functions work like this:
>>> increment_by(5, 2)
7
>>> increment_by(4)
5
>>>
  • Debug the given function print_from_stream using the default value of one of its arguments.

HackerRank Python Solution - Debugging - Words Score

  • In this challenge, the task is to debug the existing code to successfully execute all provided test files.
  • Consider that vowels in the alphabet are a, e, i, o, u, and y.
  • Function score_words takes a list of lowercase words as an argument and returns a score as follows:
  • The score of a single word is 2 if the word contains an even number of vowels. Otherwise, the score of this word is 1. The score for the whole list of words is the sum of scores of all words in the list.
  • Debug the given function score_words such that it returns a correct score.
  • Your function will be tested on several cases by the locked template code.

HackerRank Python Solution - Closures and Decorators - Name Directory

  • Let's use decorators to build a name directory! You are given some information about N people. Each person has a first name, last name, age, and sex. Print their names in a specific format sorted by their age in ascending order i.e. the youngest person's name should be printed first. For two people of the same age, print them in the order of their input.
  • For Henry Davids, the output should be:
Mr. Henry Davids
  • For Mary George, the output should be:
Ms. Mary George

HackerRank Python Solution - Closures and Decorators - Standardize Mobile Number Using Decorators

  • Let's dive into decorators! You are given N mobile numbers. Sort them in ascending order then print them in the standard format shown below:
+91 xxxxx xxxxx
  • The mobile numbers may have +91, 91, or 0 written before the actual 10-digit number. Alternatively, there may not be any prefix at all.
Input Format:
  • The first input line contains an integer N, the number of mobile phone numbers. N lines follow each having a mobile number.

HackerRank Python Solution - Functionals - Reduce Function

Given a list of rational numbers, find their product.

Concept:
  • The reduce() function applies a function of two arguments cumulatively on a list of objects in succession from left to right to reduce it to one value. Say you have a list, say [1,2,3] and you have to find its sum.
>>> reduce(lambda x, y : x + y,[1,2,3])
6

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