[Tutor] Need help with function coding.
akuma ukpo
johnnyukpo at gmail.com
Thu Mar 7 22:36:58 CET 2013
I am defining the function in one .py file and testing the function in
another .py file.
this is my code for the test:
def test_quantity_convert(self):
self.assertEqual(gallons_to_cups(0), 16)
self.assertEqual(gallons_to_cups(100), 1600)
this is my code for the defined function:
def gallons_to_cups(quant):
"""
Takes quantity 'quant' in Gallons and computes and
returns the equivalent Cup quantity
"""
return 16 * quant + 0
what am i doing wrong?
On Thu, Mar 7, 2013 at 4:28 PM, akuma ukpo <johnnyukpo at gmail.com> wrote:
> i now know how to define functions.
>
> My problem is i don't know what particular function that converts gallons
> directly to cups.
>
> However, i derived a function that converts celsius to fahrenheit (9/5 *
> temperature + 32) tested it using python and it passed the test.
>
> I need a function for gallons to cups in a similar format.
>
> On Thu, Mar 7, 2013 at 4:14 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
>
>> On Thu, Mar 7, 2013 at 1:55 PM, akuma ukpo <johnnyukpo at gmail.com> wrote:
>> > i don't know how to write functions. so i guess that is where i'm
>> stuck. i
>> > was following a tutorial on my lab document but i still did not
>> understand
>> > what to do. i will attach the pdf and python files as well.
>>
>> I am CCing the rest of the Python tutor mailing list. Please use
>> reply-to-all when responding to messages on Tutor. I'm omitting the
>> attachments you sent me, as they're not that useful to me.
>>
>>
>> Since you do not know how to write functions yet, I would strongly
>> focus on solving that confusion first. If you don't know how to write
>> any functions, then you will have difficulty with your problem set.
>>
>>
>> Has your instructor given you any information on how to write a
>> function? For example,
>>
>> http://www.learnpython.org/page/Functions
>>
>
>
>
> --
> *Akuma*
>
--
*Akuma*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130307/8bb5458f/attachment.html>
More information about the Tutor
mailing list