Sunday, 14 September 2014

Functions debate


This was our second class so far.
We were given papers by professor Heap that contained for function written in phyton language, then we were asked to try and figure out what these functions do to our sets of numbers.
I would love to go threw one of them here so
def q0(S1, S2):
 ''' (set, set) -> bool
 Return whether ...
'''
return not all({x in S2 for x in S1})

   This is our function in python! we are giving our function two sets(S1 and S2).
Our outcome is of type bool and that means It's either true(1) or false(0).
lets see what the function does! it says : return not all({x in S2 for x in S1})
so the fuction checks S1 for x first, if they are not in S2(because of the not all) then we get true and otherwise we get false.

No comments:

Post a Comment