Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following:
1. The main program calls the function enterNum 3 times. The first time enterNum is called, the main program stores the returned output in the variable xx. The second time, the returned output is stored in the variable yy and the third time in zz.
2. enterNum asks the user to enter a floating point number. This function has no input arguments and returns only one floating point output to the main program each time it is called.
3. The program then calls a function calcResult, which accepts xx, yy and zz as input arguments, adds xx + yy and subtracts zz from that term. The result of the computation is returned to the main program.
4. The main program then prints the result returned by the function calcResult. Print only from the main program, not the function.
Screenshot:-
Code:-
def enterNum():
n=int(input("Enter the number: "))
return n
def calcResult(xx,yy,zz):
result = xx+yy-zz
return result
xx=enterNum()
yy=enterNum()
zz=enterNum()
result =calcResult(xx,yy,zz)
print("The result is: ",result)
Get Answers For Free
Most questions answered within 1 hours.