Search the Community

Showing results for tags 'syntax error'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • General
    • Show Us Your Creations
    • Blog
    • Recommended Reading
  • One Stop Programming Tutorials
    • Python Beginner Series
  • Programming Languages
    • Python
    • C++
    • C#
    • Arduino
    • Other Languages

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 2 results

  1. Hey guys, I have been watching kjdelectronics on his python tutorial videos and have recently gotten to the part where you build a calculator, but I'm having trouble in the finalization process of it all. My code seems to be flawed - I keep getting a syntax error and have no idea why because I have copied the code exactly as he presents it in the video. I was wondering if anyone could look at it and tell me where my issue (bug) is located. Here is my code and a screenshot of the syntax error. #Returns the sum of num1 and num2 def add(num1, num2): return num1 + num2 #Returs the result of subtracting num1 - num2 def sub(num1, num2): return num1 - num2 #Returns the result of multiplying num1 * num2 def mul(num1, num2): return num1 * num2 #Returns the result of dividing num1 / num2 def div(num, num2): return num1 / num2 def main(): operation = input("What do you want to do? (+, -, *, /): ") if(operation != '+' and operation != '-' and operation != '*' and operation != '/'): #invalid operation print("You must enter a valid operation") else: var1 = int(input("Enter num1: ") var2 = int(input("Enter num2: ") if(operation == '+'): print(add(var1, var2)) elif(operation == '/'): print(div(var1, var2)) elif(operation == '-'): print(sub(var1, var2)) else: print(mul(var1, var2)) main()
  2. Hi, I am new to this website, but I am very enthusiastic about learning Python! After watching Kevin's tutorial number 4 over the calculator application, I tried it myself. Although I understand everything completely, and my finished project is nearly identical to his, I keep getting a syntax error and I cannot figure out why. Below I will post the code, and highlight the syntax error that shows up on CMD. Any help at ll would be greatly appreciated. Cheers! #Adds num1, num2 def add(num1, num2): return num1 + num2 #Subtracts num1, num2 def subtract(num1, num2): return num1 - num2 #Multiplys num1, num2 def multiply(num1, num2): return num1 * num2 #Divides num1, num2 def divide(num1, num2): return num1 / num2 def main(): operation = input("What do you want to do?(+, -, *, /): ") if(operation != "+" and operation != "-" and operation != "*" and operation != "/"): #invalid operation Print("You must enter a valid operation.") else: var1 = int(input("Input the first number: ") var2 = int(input("Input the second number: ") if(operation == '+'): print(add(var1, var2)) elif(operation == '-'): print(subtract(var1, var2)) elif(operation =='*'): print(multiply(var1, var2)) else(operation =='/'): print(divide(var1, var2)) main() I have redone this project three or four times, but I keep getting a syntax error every single time. Specifically, the syntax error always points to the last character where the "var" is located, regardless of what that character may be. Also, I am using Python 3.4.3. Thanks!