-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?

martineau
  • 119,623
  • 25
  • 170
  • 301
  • Two suggestions: 1) Dump VSC and use a proper (non-MS) IDE. 2) Build and argparser and implement that into your project. :-) – S3DEV Aug 25 '20 at 19:20
  • @S3DEV, curious, what's wrong with VSC (or MS IDEs in general)? – Pranav Hosangadi Aug 25 '20 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. – S3DEV Aug 25 '20 at 19:27
  • @S3DEV, "what has MS ever contributed to the OS world?" How about [VSCode](https://github.com/microsoft/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. – Pranav Hosangadi Aug 25 '20 at 20:35
  • 1
    @PranavHosangadi - “because that would preclude people from using a Windows / Mac computer”. And wouldn’t that be a great world ... ;-) – S3DEV Aug 25 '20 at 20:48

1 Answers1

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]