subject

#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_superlis t, True) -> [True, False, False]# two_dimensional_booleans(a_superlis t, 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#list.##Hint: This problem can be extremely difficult or#extremely simple. Try to use your answer or our#code from the sample answer in the previous problem --#it can make your work a lot easier! You may even want#to use multiple functions.#Write your function here!def two_dimensional_booleans(bool_super list, use_and):length_of_super_bool_list = len(bool_superlist)if use_and is False:for bool_sub_list in bool_superlist:result = []false_count = 0for num in bool_sub_list:if num is False:false_count += 1else:passif false_count == len(bool_sub_list):result. append(False)else:result. append(True)result = result[0:length_of_super_bool_list] return resultelif use_and is True:result = []for bool_sub_list in bool_superlist:true_count = 0for num in bool_sub_list:if num is True:true_count += 1else:passif true_count == len(bool_sub_list):result. append(True)else:result. append(False)result = result[0:length_of_super_bool_list] return result#Below are some lines of code that will test your function.#You can change the value of the variable(s) to test your#function with different inputs.##If your function works correctly, this will originally#print:#[True, False, False]#[True, True, False]bool_superlist = [[True, True, True], [True, False, True], [False, False, False]]print(two_dimensional_boolea ns(bool_superlist, True))print(two_dimensional_boolean s(bool_superlist, False))

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Amedian in the road will be marked with a white sign that has a black arrow going to the left of the median. true false
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
In the blank libreoffice writer document, to start the process of entering a date field into a letter, click on the insert menu. edit menu. file menu. fields menu.
Answers: 3
question
Computers and Technology, 24.06.2019 03:00
Click the "draw structure" button to activate the drawing utility. draw two diastereomers of (1z,4r)−1,4−dimethylcyclodecene and name them, including (e)/(z) and (r)/(s) notation. part 1 out of 4 draw the diastereomer containing a chiral center with s configuration here. window open
Answers: 1
You know the right answer?
#Last exercise, you wrote a function called#one_dimensional_booleans that performed some reasoning#o...
Questions
question
History, 21.11.2020 22:30
question
Mathematics, 21.11.2020 22:30
question
Health, 21.11.2020 22:30
question
Geography, 21.11.2020 22:30
question
Biology, 21.11.2020 22:30
question
Geography, 21.11.2020 22:30
question
Mathematics, 21.11.2020 22:30
Questions on the website: 13722361