Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 please Problem Solving Information Rebecca has gone to the cat store and wants to buy as many unique types of cats as possible,

image text in transcribed

Python 3 please

Problem Solving Information Rebecca has gone to the cat store and wants to buy as many unique types of cats as possible, but she only has $200. To solve her problem with a Python program, she combines all the information she gathers at the store into a table (list of lists) where each row (inner list) represents a cat containing the name of the cat (as a string), the type of cat (as a string), and the price of the cat (as an integer). An small example table of cats is as follows: [['Fido', 'Tabby', 103], ['Spot', 'Ginger', 47], ['Max', 'Tabby', 74], ['Tom', 'Black', 90]] But the real table of cats may be much longer and there could be any number of 'types' of cats. To answer a question that requires a code response, use 4 spaces to represent each indentation level. Do not use the Tab key to indent, as this will not indent and instead move you to the next field. Question 27 2 Marks Write a function good_selection(cats, selection) that takes as input: a table of cats cats as specified above and a selection of cats selection (represented by a list of row indices) and returns as output: True if each cat is a different type and the total cost of the cats is no greater than $200, and False otherwise. For example, if cats is the example table given above then good_selection(cats, [0, 1]) returns True, but good_selection(cats, [0, 1, 2]), because cats o and 2 are of the same type and the total price of the 3 cats exceeds $200. Question 28 Write a function max_types(cats) that takes a table of catscats as specified above and returns the largest number of different types of cats that can be purchased for at most $200. 3 Marks

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago