Python Forum
Python only outputting "101" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python only outputting "101" (/thread-15226.html)



Python only outputting "101" - Spuffle - Jan-08-2019

It first happened when following a tutorial for a basic calculator

num1 = float(input("Enter first number: "))
op = input("Enter  operator: ")
num2 = float(input("Enter second number: "))

if op == "+":
    print(num1 + num2)
elif op == "-":
    print(num1 - num2)
elif op == "/":
    print(num1 / num2)
elif op == "*":
    print(num1 * num2)
else:
    print("Invalid operator")

---------

101
Process finished with exit code 0
Now whenever I try to put anything at all, it always just gives out "101"

I even went back to previous things i'd coded, and running them now gives "101"


RE: Python only outputting "101" - gruntfutuk - Jan-08-2019

Your code is fine, so something must be wrong with your environment.

Are you using an IDE like PyCharm? Are you sure you are executing the correct code (run does not necessarily execute the code you are looking at)?

Try executing the code in the command line / console using the same Python Interpreter as that you have configured for the project/session in your IDE.


RE: Python only outputting "101" - buran - Jan-08-2019

What IDE do you use? PyCharm? This code is OK. I guess you have multiple files open in IDE and you run different file.


Pycharm not updating script path - Spuffle - Jan-09-2019

When I create a new script with a new tab in Pycharm, the directory for the file is not updated. Any time I need to go to a new tab, I also have to edit the configurations, locate the scripts file and manually say where it is. When changing tabs in pycharm, should it not automatically change the the one that's active on screen?


RE: Python only outputting "101" - buran - Jan-09-2019

It's not very clear what configurations you need to edit. However I guess your problem comes from running the script from the green triangle/Run command. Note that you need to select the script from the dropdown menu next to the green triangle. I.e. it always display the last run script, not the tab currently active/code visible.

https://www.quora.com/How-do-I-run-Python-script-in-PyCharm