# WSQ01 – Fun with Numbers

--Originally published at マルコ

What to Do

Ask the user for two integer values, then use those two values to calculate and show the following:

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

Code:

Capture

Fun with numbers2

 

 

 


If, elif, else

--Originally published at マルコ

If permite a que un programa ejecute ciertas instrucciones solo cuando se cumpla alguna condición. Este significa “Si”. La primera línea contiene la condición a evaluar y esta debe terminar con (:). Si la condición se ejecuta esta será “verdadera” en caso contrario se usará otro comando.

If- else: Esta estructura de control permite que un programa ejecute unas instrucciones cuando se cumple una condición y otras cuando no se cumple la condición. If es “Si”, else “si no”.

If-elif-else: Esta estructura permite encadenar varias condiciones. Elif es una contracción de “else if” y permite que se cumple una tercera condición.

Si no se cumple la primera condición, pero si la segunda, se ejecutara esta.

Si no se cumple ni la primera, ni la segunda condición, se ejecutará la tercera.

ifelse.JPG


Funciones en Python

--Originally published at マルコ

Una función es una parte de código que se puede reutilizar, el cual se encarga de realizar una determinada orden.

Para definir una función en Python se debe poner “def” seguido del nombre de la función, y dentro de los paréntesis deben de ir los parámetros, este debe finalizar con “:”. Al momento de definir los parámetros se debe tomar en cuenta que el primer valor va al primer parámetro y así sucesivamente.

python3.JPG


Uso de Comentarios

--Originally published at マルコ

Los comentarios, en programación, funcionan para explicar a los usuarios, que es lo que hace el programa, así como explicar algunas partes del código.  Estos comentarios son ignorados al momento de ejecutar el programa. Son utilices al momento de realizar un programa, ya que, puedes hacer notas de cómo funciona el programa o aclaraciones, respecto al mismo.

En pyhton los comentarios se pueden poner en dos formas:

Utilizando el símbolo “#” delante de la línea del texto, donde se escribe el comentario

Utilizando triple comilla “”” al principio y al final del comentario, el cual puede ocupar más de una línea.Comentarios.JPG


WSQ01 – Fun with Numbers

--Originally published at S' Nami Bog. Servitas Vitae

No matter how hard it is there is always a solution.

It was very hard for me to find out what I had to put in Atom, in this case the statement to find the first two numbers or variables, then the statements to make the math. I read chapters 1 through 3 of our text book. Think Python, How to Think Like a Computer Scientist”, Downey, Allen B. 2012. It helped me out a lot since I’m using the interactive version as well as some videos on Youtube; the name of the channel is GeekCompiler. After reading, testing and watching videos my last resource was to ask my classmates for help and they showed me how the statement has to be written.

screen-shot-2017-02-01-at-6-36-42-pm
Codes in Atom
screen-shot-2017-02-01-at-6-47-21-pm
Terminal running the .py file in which 4 and 3 are the variables I chose.

#WSQ01

--Originally published at Not a Programming Blog

In this post I would like to share with you the first code I did in Python3. Actually is pretty easy, but for me was a big step. Through the first weeks in this career I’ve been feeling like failing all the time, so making this program run and run as desired, was a big success for me.

In this post I will show you some basic stuff, let’s get started.

Input (text based)

Output (print)

int 

float

wsq1