Need help deriving a convertion function on python

Rick Johnson rantingrickjohnson at gmail.com
Thu Mar 7 23:15:27 CET 2013


On Thursday, March 7, 2013 2:25:42 PM UTC-6, johnn... at gmail.com wrote:
> 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

How can we help you if we have no idea of what level of programming experience you have attained. Can you write functions? Can you declare variables? What about mathematics? If you can already do all these things then make an attempt to accomplish problem "(a)" and then ask us a specific question when you run into trouble.

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

In due time grasshopper. First make an attempt to solve problem "(a)". Chris gave some great advice however i would like to insert a "step 0" into his "advice list" (this is python after all ;-).

 * STEP 0: Learn how to convert from gallons to cups using a
   pencil and paper only.

 * STEP 1: Read docs and learn about functions (if applicable).

 * STEP 2: Try to write a python function that will take one
   parameter (representing the number of gallons) and then
   perform the mathematical equations required to deduce the
   number of cups in a gallon, THEN return the result.



More information about the Python-list mailing list