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 11:40
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
question
Computers and Technology, 23.06.2019 06:00
What machine listens for http requests to come in to a website’s domain? a. a router b. a browser c. a server d. a uniform resource locator
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Me ! evelyn is a manager in a retail unit. she wants to prepare a report on the projected profit for the next year. which function can she use? a. pmt b. round c. division d. what-if analysis
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
To move an excel worksheet tab, simply right-click on it drag and drop it double-click on it delete it
Answers: 1
You know the right answer?
#Last exercise, you wrote a function called#one_dimensional_booleans that performed some reasoning#o...
Questions
question
Biology, 09.09.2019 05:20
question
English, 09.09.2019 05:20
Questions on the website: 13722360