## Sunday, December 31, 2017

### Body mass index calculator

In this case, we are going to see how to calculate a person's body mass index.
The formula to calculating it is:
So the code I made is this:

`````` p=int(input('Tell me your weight.(kg)'))
x=int(input('Tell me your height.(cm)'))
e=(x/100)**2
r=p/e
if r<=25:
print('Your body mass index is',round(r),'and you are thin.')
elif r>=30:
print('Your body mass index is',round(r),'and you are fat.')
else:
print('Your body mass index is',round(r),'and you are normal.')
``````

• First to know the person's mas weight and height we ask the using input
• Then I do the operations for height: pass the cm to m and square it
• Do the rest of the operations
• And depending on your number giving the result
An example of what the running code would look like:

Sources:
The source to all the mathematical values are in Wikipedia

## Thursday, December 28, 2017

### How to start programming Python

Python is a high-level, object-oriented programming language. It can be used to make applications,  games, powering web-pages…

To install Python on your computer go to python.org.

For Windows:

You will be asked to install Python 3.6.4 or 2.7.14, you can install whichever you want (I would install the latest version).

If you don’t know what you are doing just choose “Add Python 3.6 to PATH” and “Install Now” options.

For Mac:

The process is very straightforward, simply accept the conditions, choose where to install it, etc.

For Linux:

It normally comes pre-installed but it might be an older version, if you want to update do like in Mac

Now that we have Python installed we can start coding, search o  your computer for “IDLE” from there you will find a terminal to start programming in python.

But you don´t have to go through this mess to code in Python, you can install a code editor called “Pycharm”, It’s a very useful editor from where you can execute your code directly on the editor, it has debugging and you can run many programs at the same time.

Or you can even skip all that and program in your web browser using CodeSkulptor or repl.it

## Tuesday, December 26, 2017

### Generate numbers from 1-5

Ther are many ways to print the first five integer numbers. I’m going to give you three different ways to make this happen:

• In the first method, we use “for” with “range”: “i” will begin empty and obtain different values every time “i” gets a new value it will be printed.
• For the second method, we again use “for” but the maximum range for “i” is 5 and every time we print “i” we add one.
• For the third example, we use “while” so while “j” is smaller than 6 print “j” and ad 1 to “j”

To make the separation on the different examples I used two different sorts of methods: In the first, there isn't really much to it, just print a bunch of underscores. But in my second I used this, “print("_" * 40) print("\n")”, at first I print 40 times “_” but I could have chosen any sort of symbol, after that I ad “print(“\n”)” wich only leaves a small sapace after each line

The code:

`````` # Generate numbers from 1-5
#Method 1. With For
for i in range(1, 6):
print(i)
#Method 2. With For (A variant)
print('_____________________________________________________\n')
for i in range(5): #var i takes the values from 0 to 4
print(i+1)
#Method 3. With While
print("_" * 40)
print("\n")
j=1
while (j<6 ):
print(j)
j =j+ 1     # j += 1  ``````

The terminal: