1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
denis-greek [22]
3 years ago
11

Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,

that is a tuple of strings representing items to purchase in order of priority. (For example: ("codelab", "textbook", "ipod", "cd", "bike")) Furthermore, assume you have a variable, prices that is a dictionary that maps items (strings such as those in your shopping list) to positive integers that are the prices of the items. Write the necessary code to determine the number of items you can purchase, given the value associated with budget, and given that you will buy items in the order that they appear in the tuple associated with shopping_list. Associate the number of items that can be bought with the variable number of items.
Computers and Technology
1 answer:
max2010maxim [7]3 years ago
4 0

Answer:

budget=455

shopping_list=("codelab", "textbook", "ipod", "cd", "bike")

prices={"codelab":300, "textbook":100,"ipod":50, "cd":10, "bike":600}

number_of_items=0

sum=0

for index in range(len(shopping_list)):

   sum=sum+prices[shopping_list[index]]

   if (sum<=budget):

       number_of_items=number_of_items+1

   else :

       break

print "number of items you can purchase, for a budget of",budget,"is",number_of_items

Explanation:

A code to determine the number of items that can be purchased is above, given the value associated with budget, and given that you will buy items in the order that they appear in the tuple associated with shopping_list.

You might be interested in
Crystal detected a problem in a computer network, due to which she could not send or receive data within the network. She pings
babymother [125]
<span>Conflict of IP address in the computers. when computer are networked each computer is given a unique IP address. If two computers have the same IP there will be conflict which lead to failure in sending and receiving data within the network. It can be resolved by checking the IP addresses of each computer and correcting it.</span>
3 0
3 years ago
Read 2 more answers
On a client/server network, data does not necessarily follow the same path between the request (client) and the response (server
Andrej [43]

Answer:

SSL and HTTPS play a factor

6 0
2 years ago
In order to send a photo in a text message from your cell phone to your cousin's cell phone who lives in New Zealand, is it nece
Nata [24]

Answer: No, because all you need is WiFi for both devices and a messaging app to do it for free like iMessage.

Explanation: Please correct me if I am wrong! :)

8 0
3 years ago
Match the definition with the corresponding word
Oksana_A [137]

Answer:

Ram is your memory

that's all i know

4 0
3 years ago
Read 2 more answers
Which of the following does not reflect the second step of effective communication?
Ilya [14]

Answer:

c

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • Help me out for this one
    12·1 answer
  • Only Lysita knows the password for the question......
    10·1 answer
  • The memory unit of a computer has 2M Words of 32 bits (or 4 bytes) each. The computer has an instruction format with 4 fields: a
    14·1 answer
  • For this project, you'll be given information to create a business report using word processing software. Suppose you want to op
    11·1 answer
  • Which expression is equivalent to 3x + 3x + 3x?<br><br> From Performance Matters
    11·2 answers
  • Consider the following correct implementation of the selection sort algorithm.
    5·1 answer
  • A program with a graphical user inter-face for displaying HTML files, used to navigate the World Wide Web.
    8·1 answer
  • Explain the concepts of GIGO—garbage in, garbage out. Why do you think it’s a helpful concept in coding? How do you think it can
    8·1 answer
  • How to transfer polygon from eth to polygon in ledger live
    6·1 answer
  • To speed up data retrieval, more vehicles will be upgraded to cellular connections and be able to transmit data to the ETL proce
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!