Apr-05-2020, 09:28 PM
Hi there,
I am 2 days into learning Python (tried a year ago but couldn't continue at that time). So, I am trying to make simple Programs to learn this language and I have written the following program which does very basic of Mathematics. Now, when I run this program in PyCharm I get no error whereas when I am running from a Terminal It's not working as expected.
Another thing is It runs in a Terminal if I copy paste the File in same folder as PyCharm. Here are all the Details:
Code:
![[Image: Khy9fDp]](https://imgur.com/a/Khy9fDp)
Snapshot of when I run from Terminal (from a Folder on Desktop)
![[Image: sFemgs6]](https://imgur.com/a/sFemgs6)
Snapshot of when I give the Path of Python.exe file of Pycharm Folder and then run the file (It works then):
https://imgur.com/a/UJ39bUL
And it also works if I copy paste the Code File in PyCharm Folder.
I did try changing the PythonPath Home but that didn't fix the issue.
Any guidance on this is appreciated. Thanks !
Regards,
I am 2 days into learning Python (tried a year ago but couldn't continue at that time). So, I am trying to make simple Programs to learn this language and I have written the following program which does very basic of Mathematics. Now, when I run this program in PyCharm I get no error whereas when I am running from a Terminal It's not working as expected.
Another thing is It runs in a Terminal if I copy paste the File in same folder as PyCharm. Here are all the Details:
Code:
num1 = False
num2 = False
operator = True
while type(num1) is not int:
try:
num1 = int(input("Enter First Integer: "))
except ValueError:
print("Error: Only accepts Integers")
while type(num2) is not int:
try:
num2 = int(input("Enter Second Integer: "))
except ValueError:
print("Error: Only accepts Integers")
try:
while operator is True:
operator = input("Enter an Operator: ")
if operator == "+":
result = num1 + num2
operator = False
elif operator == "-":
result = num1 - num2
operator = False
elif operator == "*":
result = num1 * num2
operator = False
elif operator == "/":
result = num1/num2
operator = False
else:
operator = True
print("Enter a correct Symbol")
print(result)
except:
print("Unkown Error")Snapshot when I run it from Pycharm:Snapshot of when I run from Terminal (from a Folder on Desktop)
Snapshot of when I give the Path of Python.exe file of Pycharm Folder and then run the file (It works then):
https://imgur.com/a/UJ39bUL
And it also works if I copy paste the Code File in PyCharm Folder.
I did try changing the PythonPath Home but that didn't fix the issue.
Any guidance on this is appreciated. Thanks !
Regards,
