예제 #1
0
def level10(level_code='', input=''):
    if not level_code:
        levelCodeOrFail()
    elif level_code == 'Ju22w99B':
        if not True:
            pass
        else:
            print '''
modify your module so it contains documentation strings for the module and the function
the function should be modified so it contains a keyword argument called

input

the default value of the argument should be

wimp
----------------------------------------------------------------------
'''
            try:
                import myexercise
                reload(myexercise)
            except ImportError:
                print 'could not import the module myexercise'
                return
            else:
                try:
                    if myexercise.myfunction(
                            input=1
                    ) == '1' and myexercise.myfunction(
                            input=1.0
                    ) == '1.0' and myexercise.myfunction(
                            input=True
                    ) == 'True' and myexercise.myfunction(
                            input='a'
                    ) == 'a' and myexercise.myfunction(
                    ) == 'wimp' and myexercise.__doc__ and myexercise.myfunction.__doc__:
                        print '''
Ok one more!
The next level code is: jDU0R8Jz
In [1]: level11('jDU0R8Jz')
'''
                    else:
                        print '''could not find documentation strings
or the default value is wrong
or your functions reacts different than before'''
                except AttributeError:
                    print '''module imported but I could not find the function myfunction'''
                except TypeError:
                    print '''no or incorrect keyword argument'''

    else:
        print 'wrong level code'
예제 #2
0
def level9(level_code='', input=''):
    if not level_code:
        levelCodeOrFail()
    elif level_code == 'e82OApRu':
        if not True:
            pass
        else:
            try:
                import myexercise
                reload(myexercise)
            except ImportError:
                print '''
write a module called

myexercise

the module should contain a function called

myfunction

the function should take one input argument and return the input as a string
if you are ready recall this function
In [1]: level9('e82OApRu')
'''
                print "could not import the module myexercise ..yet"
                return
            else:
                try:
                    if myexercise.myfunction(
                            1) == '1' and myexercise.myfunction(
                                1.0) == '1.0' and myexercise.myfunction(
                                    True) == 'True' and myexercise.myfunction(
                                        'a') == 'a':
                        print '''
Almost done!
The next level code is: Ju22w99B
In [1]: level10('Ju22w99B')
'''
                    else:
                        print 'import went well, but the function did not work properly'
                except AttributeError:
                    print '''module imported but I could not find the function myfunction'''
    else:
        print 'wrong level code'
예제 #3
0
def level10(level_code='', input=''):
    if not level_code:
        levelCodeOrFail()
    elif level_code == 'Ju22w99B':
        if not True:
            pass
        else:
            print '''
modify your module so it contains documentation strings for the module and the function
the function should be modified so it contains a keyword argument called

input

the default value of the argument should be

wimp
----------------------------------------------------------------------
'''
            try:
                import myexercise
                reload(myexercise)
            except ImportError:
                print 'could not import the module myexercise'
                return
            else:
                try:
                    if myexercise.myfunction(input=1) == '1' and myexercise.myfunction(input=1.0) == '1.0' and myexercise.myfunction(input=True) == 'True' and myexercise.myfunction(input='a') == 'a' and myexercise.myfunction() == 'wimp' and myexercise.__doc__ and myexercise.myfunction.__doc__:
                        print '''
Ok one more!
The next level code is: jDU0R8Jz
In [1]: level11('jDU0R8Jz')
'''
                    else:
                        print '''could not find documentation strings
or the default value is wrong
or your functions reacts different than before'''
                except AttributeError:
                    print '''module imported but I could not find the function myfunction'''
                except TypeError:
                    print '''no or incorrect keyword argument'''

    else:
        print 'wrong level code'
예제 #4
0
def level9(level_code='', input=''):
    if not level_code:
        levelCodeOrFail()
    elif level_code == 'e82OApRu':
        if not True:
            pass
        else:
            try:
                import myexercise
                reload(myexercise)
            except ImportError:
                print '''
write a module called

myexercise

the module should contain a function called

myfunction

the function should take one input argument and return the input as a string
if you are ready recall this function
In [1]: level9('e82OApRu')
'''
                print "could not import the module myexercise ..yet"
                return
            else:
                try:
                    if myexercise.myfunction(1) == '1' and myexercise.myfunction(1.0) == '1.0' and myexercise.myfunction(True) == 'True' and myexercise.myfunction('a') == 'a':
                        print '''
Almost done!
The next level code is: Ju22w99B
In [1]: level10('Ju22w99B')
'''
                    else:
                        print 'import went well, but the function did not work properly'
                except AttributeError:
                    print '''module imported but I could not find the function myfunction'''
    else:
        print 'wrong level code'