Tag Archives: #WSQ08

WSQ08

Here is my code, the first time I uploaded it had a mistake. This one is the correct version.

Check it!

Fun with numbers 2.0

WSQ08

In this program I redo the WSQ03 but this time I made it with functions.

THE LINK THAT REDIRECTS YOU TO THE PROGRAM FILE ON GITHUB  IS BELOW

On to Functions

Este video me ayudo a entender funciones en phyton. veanlo es util, les dejo el link:

GITHUB

https://github.com/ValdezPatricia/Quiz-5/blob/master/WSQ08

WSQ08 – on to functions

remember WSQ03? we had to create a program that asked for two integers and printed the sum, difference, product an stuff. now we will do it again but with functios to calculate those values.

to create funcitons in python we have to define it giving it a name and variables and what we want the function to return:

def suma(a,b):

return (a+b)

ask the user to input two integers and to call the function do this:

a = int(input())

b = int(input())

print  suma(a,b)

make a function for each operation and tell the program to print it.

my code:

https://github.com/nazare52/progra/blob/master/wsq08.py

On to functions #WSQ08

This is my code for WSQ08 :  https://github.com/OscarEduardo/WSQ/tree/master

Fun with Numbers (Function) – WSQ08

First, you need to define the function, and state the variables you’re gonna use in parenthesis, they have to be different from the ones you’re gonna use to ask the user the value of these, then you do the operation under another variable, when you are done with this, type return and the name of the variable that contains said operation. You must do this for every function you create.

After that, ask for the original variables, the ones that are supposed to be different from the ones you initially did the function(s) with, create one last variable that will be equal to the name of the function you want, finally print the result using the variable you just created, which contains/is equal to the function.

Untitled

Para este programa primero investigué como llamar una función, leí en el libro y después vi algunos videos como este https://www.youtube.com/watch?v=YM0utTK7Iro:

Para llamar una función primero debes hacer la función antes del int main, poner las variables involucradas y llamarlas como en el ejemplo de la imagen. poniendo un nombre asignado a la función para poder imprimirla seguido de la función y ya en un cout pones el nombre que le asignaste para que se imprima las variables que el usuario ingresó deben ir dentro de el parentesis donde pusiste las variables X y Y

On to functions

To complete this code, I had to watch Ken’s video a few times, to be sure what he did on the top with the functions, at the end I understood, so I recommend you watch the video as well, I’ll leave the link.