Factorial calculator

In this post we will learn what is a factorial number and make a program for calculate this. A factorial number is the product of all the previous numbers, an example is:

factorial of 3= 1x2x3=6

so a posible option to calculate this thru a program is whit a whileCaptura de pantalla 2017-03-29 a las 10.27.47 a.m.

and as you can see it workssss!

Captura de pantalla 2017-03-29 a las 10.27.34 a.m.

another program to use conditionals its a good practice, see you on the next post

 

On the functions

On this post we will check one of the first things I published, fun whit numbers if you want to check it again do it here: https://etomanue.wordpress.com/2017/02/02/fun-whit-numbers/, the difference whit that post is that now its going to be done whit functions.

As a reminder the program ask for two numbers and returns:

  • The sum of the two numbers.
  • The difference of the two numbers.
  • The product of the two numbers.
  • The integer based division of the two numbers (so no decimal point). First divided by second.
  • The remainder of integer division of the two numbers.

Captura de pantalla 2017-03-16 a las 10.56.38 a.m.

As you can see the math is done on the functions and the results are printed later on the last lines of the program (19, 20, 21).

Captura de pantalla 2017-03-16 a las 10.55.57 a.m.

and thats it. This is basically an exercise to practice how to do functions. Thanks for read my blog again 😃 😄.

 

 

Simple python exercises #1

On this post we are going to do some exercises of programming there are a total of 46 but for this post we will just do 5 of them.captura-de-pantalla-2017-02-23-a-las-10-29-51-a-m

for the first one:

captura-de-pantalla-2017-02-23-a-las-10-28-39-a-m

captura-de-pantalla-2017-02-23-a-las-10-28-28-a-m

For the second one:

captura-de-pantalla-2017-02-27-a-las-11-07-02-a-m

captura-de-pantalla-2017-02-27-a-las-11-07-44-a-m

The third one:

captura-de-pantalla-2017-02-27-a-las-11-10-30-a-m

captura-de-pantalla-2017-02-27-a-las-11-09-59-a-m

A for is something to which the program would do something in this cae count each character of the string whit the counter «count»

The forth one:

captura-de-pantalla-2017-03-01-a-las-12-54-35-p-m

captura-de-pantalla-2017-03-01-a-las-12-55-30-p-m

And the last one (for this post):

captura-de-pantalla-2017-03-01-a-las-1-07-32-p-m

captura-de-pantalla-2017-03-01-a-las-1-07-20-p-m

If you have a question comment and I will try to answer it, also if you want to see the full list of the exercises : http://www.ling.gu.se/~lager/python_exercises.html

Thanks for read my blog again 🙂