Computers and Technology

#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))

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:30, yudayang2012pa9u8p
Consider the following statements: #include #include class temporary { private: string description; double first; double second; public: temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string& , double& , double& ); void setdescription(string); void setfirst(double); void setsecond(double); }; write the definition of the member function set() so that the instance variables are set according to the parameters. write the definition of the constructor so that it initializes the instance variables using the function set() write the definition of the member function manipulate() that returns a decimal number (double) as follows: if the value of description is "rectangle", it returns first * second if the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. hint: the volume of a cylinder is simply the area of the circle at the base times the height. if the value of description is "sphere" it returns the volume of the sphere with radius first. otherwise it returns -1.0;
Answers: 1
image
Computers and Technology, 22.06.2019 01:50, divine134
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy. html. erb" and “.html. erb" files in appropriate locations.
Answers: 3
image
Computers and Technology, 22.06.2019 20:00, jroy1973
Awide variety of “ apps “ are available to customize devices. which category of app does the word processing software fall into?
Answers: 2
image
Computers and Technology, 23.06.2019 12:40, melaniem50
Curriculum exam to process a resident's payment, you must click on onesite payments home page. from the a. reports b. my settings o c. transactions o d. rent tab
Answers: 1
Do you know the correct answer?
#Last exercise, you wrote a function called#one_dimensional_booleans that performed some reasoning#o...

Questions in other subjects:

Konu
Physics, 28.06.2021 16:00
Konu
Mathematics, 28.06.2021 16:00
Konu
History, 28.06.2021 16:00