Need help deriving a convertion function on python
rosuav at gmail.com
Thu Mar 7 21:40:26 CET 2013
On Fri, Mar 8, 2013 at 7:25 AM, <johnnyukpo at gmail.com> wrote:
> Good day,
> I have a computer programming assignment. I am completely lost and i need some help.
> These are the questions that are confusing me
> (a) Write a function which converts from gallons to cups2
> (b) Now we’d like to be able to convert from cups to milliliters, since metric measurements
> are easier to convert between. Implement a function which does this.
> (c) We’d also like to be able to easily convert gallons into milliliters, so implement a
> function which does this
Here's a good place to start:
After that, think about your task as three sub-tasks:
1) Get and parse input - what does your human need to tell your program?
2) Processing - the actual conversion, the meaty mathematical stuff
3) Produce output - what does your program report to your human?
Then start work on any one of the three. If you get stuck, move on to
one of the others. Once you've put some code together, test it, play
with it, and refine it. And if you get stuck, THEN come and ask for
help; but first, try to solve the problem yourself.
The purpose of this assignment is to help you learn to write code, so
we're not going to simply give you the code :) By the way, you may
find the python-tutor list more suitable, if you feel your questions
are particularly basic:
The Python tutorial really is a very good place to start. I'm
seriously considering giving it to a ten-year-old girl, granting her
just IDLE and a web browser, and seeing what she can accomplish in a
More information about the Python-list