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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:00, lindseyreneesmith7
Digital information is stored using a series of ones and zeros. computers are digital machines because they can only read information as on or off –1 or 0. this method of computation is known as the system
Answers: 1
image
Computers and Technology, 23.06.2019 02:00, rah45
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
Answers: 2
image
Computers and Technology, 23.06.2019 14:30, HarryPotter10
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
image
Computers and Technology, 24.06.2019 01:00, gymnast8900
Me if you do then you get 10 points and brainliest
Answers: 1
You know the right answer?
#Last exercise, you wrote a function called#one_dimensional_booleans that performed some reasoning#o...

Questions in other subjects:

Konu
English, 02.10.2020 20:01
Konu
Mathematics, 02.10.2020 20:01