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

CC BY 4.0 WSQ08 – on to functions by sergio is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.