Advertisement

Why its wrong?

Started by October 28, 2017 02:07 PM
1 comment, last by fastcall22 7 years, 1 month ago

Hello I am a beginner in programmin. I just begun with Python.

I write a code, but python say "syntax invalid". I use python 3.6.3 and my system is mac.

My code: print("Hello, this is a calculator. ")
print("Here you can calculate any numbers you need.")
# Here I describe for the user, what the program can do.
num_1 = input("Write the first number: ")
# Here user write the first number for calculating.
num_2 = input("Write the second number: ")
# Here user write the second number for calculating.
operator = input("Write the matematic operator you need: ")
# Here the user write the matematic opertator they neee.
if operator == '+':
    print(int(num_1) + (int(num_2))
elif operator == '/':
    print(int(num_1) / (int(num_2))
elif operator == '-':
    print(int(num_1) - (int(num_2))
elif operator == '*':
    print(int(num_1) * (int(num_2))
elif operator == '%':
    print(float(num_1) % (float(num_2))
elif operator == '**':
    print(int(num_1) ** (int(num_2))
print("Thank you dear user! ")

 

Thank'!!!

calculator.py

Ari Abdrakhmanov

Check your parentheses.  You have more opening parentheses than you do closing parentheses.

:^)

This topic is closed to new replies.

Advertisement