-1
import sys

gallons = int(sys.argv[1])
litre = gallons * 3.785411784
litre = round(litre,3)
print(gallons, "gallon(US) is equal to", litre, "litre")

For example if I were to run this code in windows cmd I would type: python "C:\Users\public\Desktop\assign2-6.py" 15

It would take 15 as the input and convert 15 into litre and return the output. How would I run this code in Visual Studio Code/Pycharm so I would not have to manually type the file location?

5
  • Two suggestions: 1) Dump VSC and use a proper (non-MS) IDE. 2) Build and argparser and implement that into your project. :-) Commented Aug 25, 2020 at 19:20
  • @S3DEV, curious, what's wrong with VSC (or MS IDEs in general)? Commented Aug 25, 2020 at 19:24
  • Why would one use an MS product for open-souce development? What has MS (ever) contributed to the OS world? Two very different ideologies. Commented Aug 25, 2020 at 19:27
  • @S3DEV, "what has MS ever contributed to the OS world?" How about VSCode? Regardless of what you think of MS's opensource contributions, using only opensource tools for opensource development sounds somewhat impossible to me, because that would preclude people from using a Windows / Mac computer, which is what quite a lot of people use. Commented Aug 25, 2020 at 20:35
  • 1
    @PranavHosangadi - “because that would preclude people from using a Windows / Mac computer”. And wouldn’t that be a great world ... ;-) Commented Aug 25, 2020 at 20:48

1 Answer 1

0

Your Solution:
You could open the VSCode Terminal and change its directory to the
file parent directory using: cd C:\Users\public\Desktop and then everytime just run the
command python assign2-6.py 15.
Or you could just take the input while the program runs instead of sys.argv[1]

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.