[Tutor] Python code

Steven D'Aprano steve at pearwood.info
Tue Nov 1 20:15:25 EDT 2016


On Tue, Nov 01, 2016 at 05:28:34PM -0400, Haley Sandherr wrote:
> Hello, I am new to python and need help with this question:
> 
> Compose a function odd ( ) that takes three bool arguments and returns 
> True if an odd number of arguments are True and False otherwise.

What part are you having trouble with?

Can you show us what code you have tried to write?

Do you know how to define a function that takes three arguments?

Here's an example of a function that takes FOUR arguments and does 
nothing:

def my_function(m, b, x, p):
    pass


Can you...?

- change the name of the function?
- change it so that it takes three arguments rather than four?
- choose more sensible names for the arguments?
- change the "do nothing" body (pass) to make it do something
  more useful?


Start by doing that, and if you still need help, show us the code you 
have come up with and we'll continue from there.



-- 
Steve


More information about the Tutor mailing list