Search the Community

Showing results for tags 'function'.



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 1 result

  1. I wrote this piece of code for practice. I don't see what's wrong in it. Please help. def add(num1, num2): """This function adds the value of arguments given to it. Only works with two arguments""" return num1 + num2 def sub(num1, num2): """This function substracts the value of arguments given to it""" return num2 - num1 def mul(num1, num2): """ This function multiplies the value of arguments given to it""" return num1 * num2 def div(num1, num2): """ This function divides the value of arguments given to it""" return num2 / num1 def main(): num1 = input("What is num1?") num2 = input("What is num2?") my_result1 = add(num1, num2) my_result2 = sub(num1, num2) my_result3 = mul(num1, num2) my_result4 = div(num1, num2) print(my_result1) print(my_result2) print(my_result3) print(my_result4) main() This is the output that I am getting in debugger window - C:\Python35\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 63680 --file C:/Users/Dell/PycharmProjects/main.py/firststep.py pydev debugger: process 2028 is connecting Connected to pydev debugger (build 172.3317.103) What is num1?5 What is num2?10 Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\pydevd.py", line 1596, in <module> globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\pydevd.py", line 1023, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Users/Dell/PycharmProjects/main.py/firststep.py", line 25, in <module> main() File "C:/Users/Dell/PycharmProjects/main.py/firststep.py", line 17, in main my_result2 = sub(num1, num2) File "C:/Users/Dell/PycharmProjects/main.py/firststep.py", line 6, in sub return num2 - num1 TypeError: unsupported operand type(s) for -: 'str' and 'str' Process finished with exit code 1