Syntax error in basic Python 3 calculator

Asked

Viewed 121 times

0

I was to program a basic calculator (add, divide, multiply, divide absolutely, find the rest of the division and power).

The code is this :

operando_1=input()

operando=input()

operando_2=input()

resultado=None

if operando_1.isdigit():
    operando_1=int(operando_1)
    tipo_operando='int'

else:
    operando_1=float(operando_1)
    tipo_operando='float'

if operando_2.isdigit():
    operando_2=int(operando_2)
    tipo_operando='int'
else:
    operando_2=float(operando_2)
    tipo operando='float'

if operando=='+':
    resultado=operando_1+operando_2
elif operando=='-':
    resultado=operando_1-operando_2
elif operando=='*':
    resultado=operando_1*operando_2
elif operando=='//':
    if operando_2==0 or operando_2==0.0:
        print('Falso.')
    else:
        resultado=operando_1//operando_2
elif operando=='%':
    if operando_2==0 or operando_2==0.0:
        print('Falso.')
    else:
        resultado=operando_1%operando_2
elif operando=='/': 
    if operando_2==0 or 2==0.0:
        print('Falso')
    else:
        resultado=operando_1/operando_2
elif operando=='**':
    resultado=operando_1**operando_2

if type(resultado)==float:
    print(format(resultado,'.2f'))
elif type(resultado)==int:
    print(resultado)

The mistake you’ve been making is this Syntax error: multiple statement found while compiling a single statement.

The problems are:

1 - I don’t know if I am running the code correctly or the right way

2 - I have done everything on Otepad, I don’t know if there is a program that makes it easier to read and/or find errors.

  • Except for the typo on line 22, here it seemed to run normally.

2 answers

0

Everything seemed to run fine except for a syntax error on line 22. I just think the program is a little confused. And answering question 2, for simple programs like this and for a quick edition I recommend the sublime text, later I could use an IDE or continue with sublime or any other.

To download the sublime: https://www.sublimetext.com/

0

1-On line 22 you are missing _ in operand='float' Execution whether or not by editor will be the same.

2- Error discovery will be given at the terminal equally

Browser other questions tagged

You are not signed in. Login or sign up in order to post.