Re: A little test for you Guys😜
Ian Kelly
ian.g.kelly at gmail.com
Tue Sep 22 15:14:10 EDT 2015
On Tue, Sep 22, 2015 at 12:43 PM, Python_Teacher via Python-list
<python-list at python.org> wrote:
> you have 10 minutes😂 Good luck!!
Sorry, I'm more interested in critiquing the questions than answering them.
> Let's define the function plural :
>
> def plural(words):
> plurals = []
> for word in words:
> plurals.append(word + 's')
> return plurals
>
> for word in plural(['cabagge','owl','toy']):
> print word
>
> Question : How could the code of the function plural be optimised?
Optimized in what way? To be faster? Use less memory? Be more readable?
> 3 Dictionaries
>
> Here are two dictionnaries :
>
> input = {
> 'foo1': 'bar1',
> 'chose': 'truc',
> 'foo2': 'bar2',
> }
> output = {
> 'bar1': 'foo1',
> 'truc': 'chose',
> 'bar2': 'foo2'
> }
>
> Question : Propose a function that returns output when you provide input ?
def f(maybe_input):
if maybe_input == input:
return output
I don't think I really understand what it is that you're asking for here.
> 3. What is the return value of hello.__doc__
hello.__doc__ isn't a function, so it doesn't have a return value. I
think you mean to ask what the expression evaluates to.
More information about the Python-list
mailing list