1

Whenever i try to run a python file on vs code with the run python file button in the terminal it pastes this into the terminal

& C:/Users/FX505/AppData/Local/Programs/Python/Python310/python.exe c:/Users/FX505/OneDrive/Desktop/FP/Projeto1.py

however the python file does not run. i have the python extention installed. i have tried reinstalling python and vscode and still nothing.

any help would be appreciated

6
  • What happens when the code "does not run"? Commented Sep 30, 2022 at 14:14
  • Right Click on python file, select open in integrated terminal, than in terminal type, py or python filename Commented Sep 30, 2022 at 14:21
  • Can you show the full code? Commented Sep 30, 2022 at 14:24
  • I am trying to run a python file with one function def is_pair(n): if n % 2 == 0: print("Yes") else: print("No") what i think is happening is that the file is running however there is no way for me to input anything Commented Sep 30, 2022 at 14:24
  • Most probably your python interpreter location is not added to system PATH variable Commented Sep 30, 2022 at 14:27

1 Answer 1

1
def is_pair(n):
    if n % 2 == 0:
        print("Yes")
    else:
        print("No")

Your code is a method definition, and has no practical application in the Python file. So you run the Python file only to load the method without displaying anything. If you want to run it, I have completed the following content for you, which you can modify as needed:

def is_pair(n):
    if int(n) % 2 == 0:
        print("Yes")
    else:
        print("No")


a=input()

is_pair(a)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.