Body-Mass Index Calculation

My Solution to 
Week 3 - Assignment 1
  • Line 1: to import string library, to check whether the given input is alphabetic or non-alphabetic - used in line 9 and 11 respectively.
  • Line 3: Input statement takes input in the form of string, else, successive calculation is not possible, hence converting the given input into float at the begening itself.
  • Line 6: This loop helps to iterate till the conditional input is met.  In this case, the loop will continue to execute until it gets M or F as input and that too only one alphabet in Upper Case
  • Line 15: In the If condition itself, we convert the given input to float on receiving input with input statement.
  • Line 20: break is used to exit the loop, after required input is received.
  • Line 33: this piece of code works with printing the out put.  Taking the upper interval in the given interval, eliminates the requirement of writing conditions to check if the calculated output between a particular interval.
  • Output to the given code is shown below, in a separate picture.
gallery/bmi code
gallery/bmi code output

The following is the code that I have written in Google Colab, with Python V3.0, for the given problem 1 -
thinking, it is good to share and can be helpful for me in future.

The following will be the output to the above code.

Factorial - code with and without Function call


Recursive Function - The function that calls itself.


Compute Ratio:


Function to Iteratively sum up the value