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
The design strategy that starts with a global view of the entire problem and breaks the problem down into smaller, more manageab
In-s [12.5K]

Answer:

Top down design

Explanation:

Top-down design is an approach that is used to break down the problem into the smaller subpart so that it can be manageable into more clear form.

C programming is the example of a top-down approach while C++ is the example of the bottom-up approach.

The advantages of the top-down design approach are:

1) easy to manage

2) easy to find the error

3) easy to debug

4 0
3 years ago
Amy wants to insert clip art in her document, and she wants it to be in gif file format. How can she look for only clip art in a
Nikitich [7]
Go to the motion pics or gifs

5 0
3 years ago
Which of the following does not accurately describe asynchronous communication?
worty [1.4K]

Answer:

A. While new media is dependent on whether users function in real-time or delayed mode, feedback is not as timely when communication is asynchronous.

Explanation:

Asynchronous communication can be defined as a data communication technique in which exchange of data between a sender and a recipient isn't in real time.

There's usually a time lag, meaning it doesn't require the recipient to respond immediately.

For example, responding to an email or text several hours later.

6 0
3 years ago
Read 2 more answers
Which of these statements would create a variable but not assign anything to it?
Ugo [173]

Answer:

variable = null

Explanation:

that one would fasho

7 0
3 years ago
Read 2 more answers
A poem for coduction
Nataly_w [17]
I don't know if you want a poem about conduction but if so here ya go

no matter how the heat
different temperatures meet
hot to cold how it's done
4 0
4 years ago
Read 2 more answers
Other questions:
  • You would like to know how many cells contain data. Which function should you use? COUNT MIN SUM ABS
    14·1 answer
  • In regard to protective actions for explosive devices, the area where the blast originates is referred to as ___________ perimet
    8·1 answer
  • Given the strings s1 and s2 that are of the same length, create a new string consisting of the last character of s1 followed by
    10·1 answer
  • Yolanda lost her left foot during her military service, but she has been issued a prosthetic that enables her to walk normally,
    13·1 answer
  • What kind of attack allows for the construction of LDAP statements based on user input statements, which can then be used to acc
    7·1 answer
  • Mac or PC (need opinions please)<br><br> Why did you choose Mac/PC?
    10·2 answers
  • What are the differences, physically and logically, between the two printing configurations: Network-attached Printing and Netwo
    7·1 answer
  • Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
    9·1 answer
  • Which is the highest level of the hierarchy of needs model?
    14·1 answer
  • What is Frederick Taylor attributed to doing
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!