wsq05

--Originally published at Tomas Enciso

This one almost Identical to a past wsq except for this one functions took care of everything. The program grabs 2 numbers that the user inputs, of course they have to be integers, and each functions either sums, subtracts, multiplies, divides, or shows the remainder of those 2 numbers.

Screen Shot 2017-05-04 at 6.36.17 AM

Screen Shot 2017-05-04 at 6.37.02 AM

In this example I used 5 and 7, in the code you may have noticed that there is a while and a print statement, this just so the user doesn’t enter 0 second because then there would be an error when trying to divide a number with 0.


WSQ-05

--Originally published at Program

You will go back and do WSQ01 – Fun with Numbers again.

But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.

You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.

if you wanna see an easier way go here:

https://chinbrow.wordpress.com/2017/01/30/calculator/


# WSQ 05 – On To Functions

--Originally published at マルコ

What to Do

You will go back and do WSQ01 – Fun with Numbers again.

But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.You will go back and do WSQ01 – Fun with Numbers again.

You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.

Funnum

Funnum2

Featured image: 

http://www.pixiv.net/member_illust.php?mode=medium&illust_id=34076723

 

 


Functions in Python

--Originally published at Programming

In this post we will:

¡Recycle!

2fazaqyizlltuiie0

Gif from: http://giphy.com/gifs/helpsgood-2FazaqYizLltuIIE0

But not as the usual way. We will use the programm we made in this post: Fun with numbers. We will do the same, but now with functions. First look how it runs:

Captura de pantalla 2017-03-09 a la(s) 10.53.42

It’s the same you already saw before. But now look at the code:

Captura de pantalla 2017-03-09 a la(s) 10.51.10

Let’s explain how it works.

(This video may help you to understand better Python functions: Python Tutorial for Beginners).

The first part as you see, is just declare functions. Thats why you write def and after the name and the variables in brackets. We need it give us the operation, that why we write return and the operation to perform, that we already describe in the post Fun with numbers. The inputs will be the same way, and the thing that changes is the math operations. We are using functions, so we don’t need to perfom it like the traditional way. We just call the function and finally we print it ?


WSQ-05

--Originally published at Site Title

Para realizar este programa volvemos a WSQ-01 y debemos desarrollar una proto-calculadora pero que esta vez opere con funciones.

Para realizarlo, simplemente definimos cada función. Una función debe sumar, la otra restar, la otra, multiplicar, etc. Una vez que las funciones están operativas, las insertamos en el programa principal y este se ejecuta. En vez de realizar las operaciones, tomará las operaciones que vienen en cada función.

captura-de-pantalla-14

Ejecutado en Python:

captura-de-pantalla-15

Para realizar este programa me basé en mis conocimientos básicos de programación.