Python Convert Shell Script
Python Convert Shell Script
van Bevan Sharp @beva
- 66
- 0
- 0
Introduction
I wanted to write a Python shell script to do some simple conversions on the command line, both to practice my Python coding and to develop something useful. Conversions include: Miles to Kilometers, Kilometers to Miles, degrees Celsius to degrees Fahrenheit and degrees Fahrenheit to degrees Celsius. This could be expanded on in the future with other types of conversions, but pretty happy with how it works so far for a first iteration.

Supplies
Little bit of searching on Google for how to write a Python shell script and how to use arguments from the command line in a Python shell script. The rest I worked out from what I learnt about Python in this course.
The Python script code
Here's a screen shot of the Convert Python shell script I wrote. For those who have finished the course you probably recognise the mathematical formulas I used in the conversion functions. Also worth noting that if you don't pass any arguments to the script (the kind of conversion to do and the amount to convert by) the script will give help information now how to use it with examples.

Updated Python script code
I updated the Python script code adding in conversion options for weights with: Pounds to Kilograms and Kilograms to Pounds. A snapshot of the updated code is as follows:


0 opmerkingen
Log in of doe gratis mee om te reageren