CP 4.3.11 TwoDAndOr.py - #Last exercise you wrote a function called#one_dimensional_booleans that performed some reasoning#over a one-dimensional list

CP 4.3.11 TwoDAndOr.py - #Last exercise you wrote a...

This preview shows page 1 - 2 out of 2 pages.

#Last exercise, you wrote a function called #one_dimensional_booleans that performed some reasoning #over a one-dimensional list of boolean values. Now, #let's extend that. # #Imagine you have a two-dimensional list of booleans, #like this one: #[[True, True, True], [True, False, True], [False, False, False]] # #Notice the two sets of brackets: this is a list of lists. #We'll call the big list the superlist and each smaller #list a sublist. # #Write a function called two_dimensional_booleans that #does the same thing as one_dimensonal_booleans. It should #look at each sublist in the superlist, test it for the #given operator, and then return a list of the results. # #For example, if the list above was called a_superlist, #then we'd see these results: # # two_dimensional_booleans(a_superlist, True) -> [True, False, False] # two_dimensional_booleans(a_superlist, False) -> [True, True, False] # #When use_and is True, then only the first sublist gets #a value of True. When use_and is False, then the first #and second sublists get values of True in the final
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Fall '19
  • susan lee

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture