Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 10: Set membership Given the sets defined in Question 9, identify the following subgroups (as in, sets). As above, write the Python code that

image text in transcribed
Question 10: Set membership Given the sets defined in Question 9, identify the following subgroups (as in, sets). As above, write the Python code that will find the answer. 3. Animals that are farmed b. Mammals that are not farmed c Things that are farmed as well as caught, but which are not mammals. Question 11: Combinations Julianne would like to plan recreational activities she can do while at home but can't decide what activity to do. To make her decision she's going to enumerate various possibilities based on the level of physical exertion (she will add some form of physical activity such as running on the spot to make an activity intensel. the kind of activity and what clothing she'll wear. Given the following sets of options, write set comprehensions that will generate the possible combinations described below. Note that the order of the pairs or triples generated should match what is asked for in the question. exertion = { 'relaxed', "intense' } activities = { "TV watching", "sourdough baking', 'neighbour spying' } clothing = { 'in pyjamas', "in work clothes', 'in ski gear', 'in a tuxedo' } 3. Generate all pairs of activities and clothing. b. Generate novel kinds of activity by combining them as pairs. These will include pairs with the same activity type repeated (for instance, you could imagine that (TV watching. TV watching) is watching someone on TV who is watching TV, like the show Gogglebox) Generate all triples (3-tuples) of exertions. activities and clothing Question 12: Bags (multisets) 3. Write a dictionary literal that compactly represents the bag/multiset ("like. "most. "I" "like. 'sets. "and, 'logic. "but' 'sets: "I. "like. "most"} b. Create a Counter object of that multiset by passing the collection of words to the Counter () function (that is, do not manually define the counts like the example in the script file). (Hint: you will need to make a small change for it to correctly count the entries.) Referring to the Counter you created and stored in the answers dictionary (that is, using ans[ 'Q12 b' ]), write the expression Boy\\ stop_words in Python (where Boy is the Counter you created earlier and stop_words is already defined in the script). The result is your original bag (of words) with some very common English words removed. d. Again referring to the Counter you created in part b. write the Python equivalent of the multiset operation Bay nstop_words (which will identify which stop words are present in the bag. and their counts). Question 13: Functions (ILO 2 only) Both your code and written answers to this question will be stored in entries in the answer dictionary, although your written answers will not be automatically assessed. There is a function called test_this defined in the script file. You must not modify its implementation. You are to write both natural language answers about its operation and provide sets of inputs that will test (reach) each path through the function. a. Given what you can see in the code, write short description (1 or 2 sentences) of the function's domain and codomain. If you wish, you can use letters like N. Z and R to refer to the sets of natural numbers, integers and real numbers. (There are multiple correct answers. Now you will define Python sets that will specify test cases for the function. Your aim is that, used in combination, they would reach every exit point and also test boundary cases; you will not be checking that it gives the correct answer. Aim to make the sets as small as you can (in other words, do not make them extremely large to ensure coverage, craft them cleverly). b. Write a Python set literal containing test values for the q parameter c Write a Python set literal containing test values for the p parameter d. Write a Python set literal containing test values for the x parameter And finally... e. Your answers to many of the above questions, including this one. are stored in a Python dictionary. Thinking about this dict object as a function, how would you describe its codomain using natural language? A one sentence description is sufficient

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions

Question

A(n) ________ is a set of instructions

Answered: 1 week ago