1
I’m new to Python and programming and I’m trying to create a calculator (interactive way I think kkkk) using the content I’m learning to create functions, but it’s giving this error on the last line (where I am trying to call the functions, because when I put to run without this line only processed the program successfully without showing anything). Follow the error that appears and my code:
(numero(calculus(message)) Typeerror: calculo() Missing 2 required positional argument: 'num2'
def numero(num1,num2):
num1 = float(input("Digite um numero: "))
num2 = float(input("Digite outro numero: "))
def calculo(result,num1,num2):
calculo = int(input("Digite um o respectivo numero de acordo com o calculo que deseja realizar \n 1-)adição \n 2-)subtração \n 3-)divisão \n 4-)potenciação \n 5-)multiplicação "))
if calculo == 1:
result = num1 + num2
elif calculo == 2:
result = num1 - num2
elif calculo == 3:
result = num1 / num2
elif calculo == 4:
result = num1 ** num2
elif calculo == 4:
result = num1 * num2
def mensagem(result):
print(" o resultado é",result)
(numero(calculo(mensagem)))
In fact it gave this error with the number too, but I have no idea how to solve, I know it is a simple problem but I am in difficulty. Can you help me?
So I made the changes that you said, when I changed the indentation (in "if" and "Elif" which was what I think you were referring to) it was wrong, maybe I got it wrong too. And I added the Return at the end but the error persists, now speaking that only one argument is missing, it is like this: message(calculus(number)) Typeerror: calculus() Missing 1 required positional argument: 'num2'.
– Victória Julia
@Victóriajulia modified your code take a look at it in my answer
– Killdary Aguiar de Santana