Just started using functions in python 2.7.5, working on assignment for school but was having problems with output of the correct results, I want the user to enter 3 numbers and get the product of them. I can get the sum of 2 numbers but my issue is that I can get the input from the user but the output either doesn't display correctly or I get an error, here is my code this far: (I'm very new to coding so please be as detailed as possible)
#first function for getting numbers
def getValue():
num = float(raw_input("Enter a number: "))
return num
#The second function to calculate the total
def getSum(first, second):
total = first + second
return total
def getProd(n1,n2,n3): #my attempt for getting the product of 3 numbers entered
itotal = n1 * n2 * n3
#The third function to display the data
def displayData(first, second, total):
print("The first value is = ", first);
print("The second value is = ", second);
print("The Total is = ", total);
def main():
isum1 = 0 # need to initialize the needed variables
isum2 = 0 #how do I enter for a third number for the product?
isum3 = 0
totalSum = 0
isum1 = getValue() #call the function to get a number
isum2 = getValue()
isum3 = getValue()
itotal = getProd(isum1, isum2, isum3) #declared itotal as var for getting the
#getProd function
totalSum = getSum(isum1, isum2)
displayData(isum1, isum2, totalSum) #unclear how to write the display correctly
main()
my issue is I need a product function but can't seem to get it correct. if I put an isum3 and define a new function as getProd for example, it doesn't display correctly,
getProdfunction andisum3defined?