Fibonacci series- Quiz 8

--Originally published at Paola Gutierrez Blog

En este post voy a desarrollar el quiz 8 que se trato a base de la serie fibonacci. Desarrolle 2 diferentes programas usando funciones diferentes, uno estuvo mas fácil que el otro, pero al final los 2 nos daban el mismo resultado.

Programa 1:

Empezamos con el programa definiendo la función fib con la variable dentro de paréntesis, incluimos contadores en los cuales igualábamos num a 2, x a 0 y por ultimo y a 1. Después agregamos un while para evaluar si la variable era mayor o igual al contador de num, asignamos la letra z como una variable que almacena el resultado de suma x + y, después de esto igualamos x a y, al igual y con z, y al num lo igualamos a num y le sumamos a 1, regresando z. Acabada la función le preguntamos al usuario cual es el numero que quiere evaluar y por ultimo imprimimos el resultado final.

Programa terminado:

Captura de pantalla 2017-03-16 a las 11.00.08

Resultados:

Captura de pantalla 2017-03-16 a las 11.00.56


WSQ06 – Factorial Calculator

--Originally published at Paola Gutierrez Blog

En este post el usuario nos proporcionara un numero y nosotros calcularemos su factorial.

A este programa le di mi toque personal, comencé dandole la bienvenida al usuario, después comencé definiendo la función a usar, después yo abri un if en el cual puse que si el numero dado por el usuario es menor que 0 es 1, pero si no se hace la operación completa de factorial así dandole al usuario su respuesta final. Le preguntamos al usuario el numero a calcular, almacenando al mismo tiempo. Por ultimo imprimimos resultados finales.

Programa terminado:

Captura de pantalla 2017-03-16 a las 9.37.10

Resultado final:

Captura de pantalla 2017-03-16 a las 9.49.00

 

 


WSQ 05 – On To Functions

--Originally published at Paola Gutierrez Blog

El post de hoy es demasiado similar al de fun with numbers, solamente que en este usamos  una function para cada operacion realizada.

Al principio del programa como en todos importamos las biblioteca matemática, dando paso al desglose y desarrollo de cada función de acuerdo al la operacional realizar, en este caso comenzamos definiendo la función con un def, exponiendo aquí nuestra función y los valores a evaluar, esta acción la realizamos con cada función a evaluar, siempre dandole una variable a la operacion y regresando el valor resultante.

A continuación le preguntamos al usuario los valores que quiere evaluar, directamente asignándole una variable que lo va almacenar, por ultimo vamos a imprimir los resultados de cada operación realizada.

Programa completo:

Captura de pantalla 2017-03-16 a las 7.57.54

Resultados:

Captura de pantalla 2017-03-16 a las 7.55.52


WSQ04 – Sum of Numbers

--Originally published at Paola Gutierrez Blog

En este post vamos a hacer un programa que calcule los rangos de números enteros y luego calcule la suma de los números en esos rangos.

Para comenzar vamos a importar la biblioteca matemática, a continuación vamos a usar la función def con la cual vamos a poner suma usando lower y upper, después pondremos un contador incializado en 0, luego usamos la función : for valor in range(lower,upper+1), después vamos a igualar el total con la suma del total con el valor, regresando el total.

A continuación le dimos la bienvenida al programa, dando paso a preguntarle al usuario las cantidades a evaluar y al mismo tiempo almacenándolas como una variable. Por ultimo almacenaremos los resultados en una variable, para el momento de imprimir sea mas fácil darle al usuario un resultado conciso.

Programa terminado:

Captura de pantalla 2017-03-16 a las 0.22.10

Captura de pantalla 2017-03-16 a las 0.25.00

 


WSQ 02- Temperature

--Originally published at Paola Gutierrez Blog

En este post vamos a hacer un programa, en el cual el usuario nos proporciona una temperatura en Fahrenheit y luego lo convertirá en Celsius.

Primero importamos la biblioteca matemática. Después vamos a declarar la variable, en la cual vamos a albergar el valor que el usuario nos va a proporcionar. Después vamos a colocar la formula a usar, en este caso la declare con una variable llamada temp2, después vamos a imprimir el resultado.

A continuación evaluaremos el resultado usando if, esto quiere decir que al evaluarlo, si la temperatura es alta el programa te lo va a decir, pero en caso contrario el programa te dirá que la temperatura es helada.

Ejemplo:

Captura de pantalla 2017-03-15 a las 18.24.36

Resultados:

Captura de pantalla 2017-03-15 a las 18.24.53


WSQ01 – Fun with Numbers

--Originally published at Paola Gutierrez Blog

En este entrada nueva del blog vamos a hacer algo súper sencillo, vamos a hacer un programa en el cual a partir de dos valores proporcionados , se realicen las operaciones matemáticas básicas.

Primero vamos a importar la librería matemática, para realizar las operaciones. Después de esto vamos a pedirle al usuario los 2 números, declarándolos con una variable que almacene los números recibidos, en este caso usamos la función input. A continuación desglosando las operaciones a realizar, en este caso usamos: suma, resta, multiplicacióndivisión, etc. Por ultimo vamos a imprimir en la pantalla los resultados, vamos a usar print y la variable en la que guardamos el resultado de esta manera, el usuario conocer su resultado.
Captura de pantalla 2017-03-15 a las 17.25.24
Resultados en pantalla:
Captura de pantalla 2017-03-15 a las 17.27.51

 

 


Pick a Number -WSQ 03

--Originally published at Paola Gutierrez Blog

In this publication we develop a program that selects a random integer in the range of 1 to 100, you could say that it is easy but if you have a minimal error, the program does not work (own experience).
We will start importing from the library the radom function, we will give x value a range between (1,100), the program like you can do things as simple as your name or welcome. After the presentation of the program we must add counters equal to 0 to store the different processes that are performed.

In this opportunity, at the moment of entering in which we will! = To give it a difference of x, and we will integrate the number of tries in which the program can be realized.

We will start by asking a numeor and we will analyze it with 2 if one to say if the value of x is bigger you need to reduce it and on the contrary if the value is very small if you need to increase it, if the result is equal to that the machine has a happiness, But If the points of the attempts of the machine will end the process and say a sorry.

In each of the links if you have to add a counter that matches the number of attempts already taken, giving a + 1.

 

16788113_1533327513358936_1804293810_n

 

Results:

16788113_1533329713358716_573165028_n


Hola mundo with Comments

--Originally published at Paola Gutierrez Blog

This post is something different than the previous one, it is something easy ,is a hello world accompanied by comments
In this post I will talk about how to make a single line of code, which is totally easy, everyone can do it.

1st step: You need to open the program atom, in this program we need to write the language to be use.

2nd step: We use the function print, this function is language use as a system of information output, we need to put parentheses and double quotes, after this you need to write the text .

When we are going to use comments, we need to use the # symbol, after that we will add the text that we will put as an annotation.

16699808_1527433220615032_1314333216_n16729874_1527433210615033_1531800142_n


Minimum and Squares ( Quizz 4 )

--Originally published at Paola Gutierrez Blog

In this post we talk about minimum and squares, first, you need to import the math library. After we need to wrote the functions to use , at the end of declaring the functions  you will have to put return the value, in this case, you need 2:

  • def minimum_three(x, y, z):  # returns the value that is smallest of x, y and z
  • def sum_squares(x, y, z): # returns the value of the sum of squares of x, y, z

After need to declaring  variable and ask the user the numbers we need to calculate, and the end you need to print the results .

This is the program:

whatsapp-image-2017-02-02-at-11-10-20-am

 

This is the results:

whatsapp-image-2017-02-02-at-11-15-00-am


Functions (Quiz 3)

--Originally published at Paola Gutierrez Blog

In this article, I will talk about how to create a program with functions.
First, you need to import the math library.

16425701_1515214925170195_1337098460_n

After we need to wrote the functions to use , at the end of declaring the functions  you will have to put return the value, in this case, you need 2:

def square_root(x): (to make square root)

16426451_1515212411837113_1369144925_n

def cube_root(x): (to make the cube root)

16426451_1515212411837113_1369144925_n

We have to ask the user what is the number to assess, at the same time declaring it as a variable.

16468782_1515212401837114_1824257549_n

Then you have to place an if ,in case the user decides to provide a negative number, which the program not explote.

16467151_1515214861836868_1886379236_n

For the end you need to print  the results that gives to the operations and the programhave to mention  “The program cannot handle negative numbers” if the user provide a negative number

16465926_1515214848503536_467170217_o

These are the results.

16466148_1515246268500394_289080278_o