A list of tuples named cereal_data contains calorie and price details of different cereals. Each tuple...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A list of tuples named cereal_data contains calorie and price details of different cereals. Each tuple contains three elements. The first element of each tuple is the cereal name, stored as a string. The second element is the calorie content and the third element is the price per 100g. The calorie content and the prices are stored as floats. Write a function chosen_cereals (cereal_data, dollar_amount, cal_amount), which returns a list of cereal names which costs less than the dollar amount and contains less calories than cal_amount. Your function should return None if no records are available that meet the given criteria. See the examples given below (doctests). (6 marks) Note: Your function should work with any database given. def chosen_cereals(cereal_data,dollar amount,cal_amount): Input: A list of tuples with the cereal name, calorie content and the price per 100g. Output: A list of cereal names that costs less than the dollar amount and contains less calories than cal_amount. Examples: >>> database = [('cherion', 110.1.25),('milco',156,2.80),('wheatabits',92,0.85),\ ('cocopix',205,3.60), ('corn fun',123,2.30),('yumbix',167,3.15)] >>> print(chosen_cereals(database,2.00, 100)) ['wheatabits'] >>> print(chosen_cereals (database,3.20,150)) ['cherion', 'wheatabits', 'corn fun'] >>> print(chosen_cereals(database, 1.50,75)) None >>> print(chosen cereals(database,0.75,150)) None A list of tuples named cereal_data contains calorie and price details of different cereals. Each tuple contains three elements. The first element of each tuple is the cereal name, stored as a string. The second element is the calorie content and the third element is the price per 100g. The calorie content and the prices are stored as floats. Write a function chosen_cereals (cereal_data, dollar_amount, cal_amount), which returns a list of cereal names which costs less than the dollar amount and contains less calories than cal_amount. Your function should return None if no records are available that meet the given criteria. See the examples given below (doctests). (6 marks) Note: Your function should work with any database given. def chosen_cereals(cereal_data,dollar amount,cal_amount): Input: A list of tuples with the cereal name, calorie content and the price per 100g. Output: A list of cereal names that costs less than the dollar amount and contains less calories than cal_amount. Examples: >>> database = [('cherion', 110.1.25),('milco',156,2.80),('wheatabits',92,0.85),\ ('cocopix',205,3.60), ('corn fun',123,2.30),('yumbix',167,3.15)] >>> print(chosen_cereals(database,2.00, 100)) ['wheatabits'] >>> print(chosen_cereals (database,3.20,150)) ['cherion', 'wheatabits', 'corn fun'] >>> print(chosen_cereals(database, 1.50,75)) None >>> print(chosen cereals(database,0.75,150)) None
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these operating system questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Data-2-Go manufactures and sells flash drives. The company produces only when it receives orders and, therefore, has no inventories. The following information is available for the current month:...
-
Consider the following diagram of the market for bank reserves, in which the current equilibrium value of the federal funds rate, 2.50 percent, also corresponds to the Federal Open Market Committee's...
-
Which of the following integrals are improper? Why? a. 0 sec x dx b. c. d. '4 dx Jo x - 5
-
Defendants Jack and Claire Lein owned and lived on Willow Creek Farm from 1980 through 2004. The farm manager, Stewart, and his girlfriend, plaintiff Tambra Curtis, also lived on the farm during this...
-
Company is a small but growing manufacturer of telecommunications equipment. The company has no sales force of its own; rather, it relies completely on independent sales agents to market its...
-
1. Brody knows that he can afford a monthly mortgage payment of $1500. The bank will offer him a mortgage rate of 2.14% compounded monthly over a 25 years period. Calculate the most expensive home...
-
The figure to the right illustrates the average total cost (ATC) and marginal cost (MC) curves for an apple farmer. Assume the market for apples is perfectly competitive. If the market price for...
-
You are discussing your retirement plan with Dan Ervin when he mentions that Sarah Brown, a representative from Skandla Financial Services, is visiting West Coast Yachts today. You decide that you...
-
You are forming an equally weighted portfolio of equities. Many equities have the same beta of 0.84 for factor 1 and the same beta of 1.69 for factor 2. They also have the same expected return of 11...
-
The model for the RC circuit shown in Figure P42 is For RC = 0.2 s, plot the voltage response o (t) for the case where the applied voltage is a single square pulse of height 10 V and duration 0.4 s,...
-
Prove that the portfolio-weighted average of a securitys sensitivity to a particular factor is the same as the covariance between the return of the portfolio and the factor divided by the variance of...
-
The UK is found to have two factors, GDP growth and the inflation rate, that generate the returns of all equities. The expected GDP growth rate in the next year is 2 per cent and the expected...
-
The Rafi M. Company, which has been in business for three years, makes all of its sales on credit and does not offer cash discounts. Credit sales, customer collections, and write offs of...
-
Imagine you are the HR manager at a company, and a female employee came to you upset because she felt a male coworker was creating a hostile work environment by repeatedly asking her out on dates...
-
Write a program that concatenates two linked-list objects of characters. Class ListConcatenate should include a static method concatenate that takes references to both list objects as arguments and...
-
Modify Exercise 24.4 to provide a ComboBox and a TextArea to allow the user to perform a query that is either selected from the ComboBox or input into the TextArea. Sample predefined queries should...
-
Demonstrate that the escape sequence \t causes a tab to be issued to the output. Note that your output will depend on how tabs are set on your system. Use the string "before\tafterbefore\t\tafter"
-
Online electronics retailer Kogan has announced an initial public offering to raise $50 million, with plans to list on the ASX at the end of June. Kogan, founded in 2006, said it would have a market...
-
For each company below, fill in the missing data. Each company is independent. Sales Beginning finished goods Cost of goods manufactured Ending finished goods Cost of sales Income Statement Company X...
-
Innovative Computers Pty Ltd began manufacturing inexpensive computers for the student market on 1 July 2018. The variable costs of manufacturing each computer are as follows. During the year ended...
Study smarter with the SolutionInn App