Write a Python script that uses the sys module to perform the following tasks: 1. In a main method: a. Read and print the command-line arguments when the script is run. b. Print the Python path (the directories where Python is looking for modules to import). c. Print the Python version. d. Print the platform name. 2. The main() function must only run automatically if the module is being run directly, not when imported. Here is a screenshot of the expected behavior, testing all scenarios described above. Replicate this functionality in your script, including the formatting and outputs of all messages. The program must work for any arguments that the user provides after the name of the script.
Write a Python script that uses the sys module to perform the following tasks:
1. In a main method:
a. Read and print the command-line arguments when the script is run.
b. Print the Python path (the directories where Python is looking for modules to
import).
c. Print the Python version.
d. Print the platform name.
2. The main() function must only run automatically if the module is being run directly, not
when imported.
Here is a screenshot of the expected behavior, testing all scenarios described above. Replicate
this functionality in your script, including the formatting and outputs of all messages. The
program must work for any arguments that the user provides after the name of the script.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images