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
Explain what the hazard detection unit is doing during the 5th cycle of execution. Which registers are being compared? List all
kondaur [170]

Answer:

<em>The registers that are compared are instructions 3 and 4</em>

<em>Explanation:</em>

<em>From the question given,</em>

<em>Recall that we need to explain what the hazard detection unit is doing  during the 5th cycle of execution and which registers are being compared.</em>

<em>Now,</em>

<em>The instructions on the 5th cycle, at the stage ID/EX and IF/ID:</em>

<em>The instruction values are in ID/EX : sub $t2, $t3, $t6 (instruction 3)</em>

<em>The instruction values are in IF/ID: sub $t3, $t1 $t5 (instruction 4)</em>

<em>The register $t3 is compared in the instructions 3 and 4</em>

<em>The hazard detection unit between instruction 4 and 5t o be compared, it need to find out the values of $t1</em>

<em />

7 0
3 years ago
Typically, you need to score _____ or higher on an AP exam to receive college credit for the AP course in the subject tested by
ss7ja [257]

the answer is A). 3 or higher

7 0
3 years ago
Read 2 more answers
when a driver receives a text while driving, what can 2022 versa’s hands-free text messaging assistant do?
Lena [83]

Answer:

It can translate text to voice

Explanation:

7 0
2 years ago
What is an electronic medical record
Airida [17]
EGC . medical research science
3 0
3 years ago
How long will my chromebook last if it is at 30 percent
Marta_Voda [28]

Answer:

You can see an estimated battery life time.

Explanation:

To see it simply put your mouse over the battery icon, don't click it and it should give you the life it has left in hours:minutes format.

5 0
3 years ago
Other questions:
  • To keep a desktop computer or a server powered up when the electricity goes off in addition to protection against power fluctuat
    8·2 answers
  • How much does a Canon PowerShot G7X cost in America?
    14·1 answer
  • Green field county stadium is planning to conduct a circket match between two teams A and B. A large crowd is expected in the st
    13·1 answer
  • Question 1 Multiple Choice Worth 5 points)
    10·1 answer
  • 1. Write a class for time objects that store three integer values for hour, minute, and second. Also, write a program to test th
    13·1 answer
  • What is the output of the C++ codeabove?
    14·1 answer
  • A network consists of 75 workstations and three servers. The workstations are currently connected to the network with 100 Mbps s
    12·1 answer
  • CreatePolicies<br> I need help with this in java.
    8·1 answer
  • _______ is a medium-range wireless network. ________ is a medium-range wireless network. Cellular radio LTE UWB Wi-Fi
    12·1 answer
  • Why is computer science hardware needed to solve problems with computers?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!