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
Place the steps in order for creating a Custom Search Folder in Outlook 2016.
TEA [102]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct order for creating Custom Search Folder in Outlook 2016 is given below:

  1. Click the Folder tab
  2. Click the New Search  Folder
  3. Open the Custom Search
  4. Choose your criteria and  
  5. Select folder in pane to
  6. Click ok to execute the search.

5 0
3 years ago
Read 2 more answers
Kayla is working on a document for her business meeting. She wants to save this document with another name. Which option should
Fittoniya [83]
Kayla could use “save as” to rename the document.
5 0
3 years ago
Assume that sentence is a variable of type String that has been assigned a value. Assume furthermore that this value is a String
disa [49]

Answer:

//get the sentence from the user

          Console.WriteLine("Enter your sentence");

           //read the user information

           string ans = Console.ReadLine();

           //check if sentence ends with period

          if(!ans.EndsWith("."))

           {

               Console.WriteLine("Sentence should end with period");

               Environment.Exit(0);

           }

           //declear empty string firstword

           string firstWord = "";

           //split the requested sentence using single space character

          string[] splitans =  ans.Split(' ');

           //assign firstword

           firstWord = splitans[0];

           //print out firstword

          Console.WriteLine(firstWord);

Explanation:

The program uses c#.

5 0
3 years ago
What does UDP stand for?
sleet_krkn [62]
User Datagram Protocol
3 0
3 years ago
Read 2 more answers
You can put a small level on your camera to help keep the horizons straight? TRUE OR FALSE
anastassius [24]
The answer is true and i believe it is best to put it at the 4 intersecting points<span />
5 0
3 years ago
Read 2 more answers
Other questions:
  • How do you scan a qr code on your iPhone
    5·2 answers
  • Do you think technology and social media have made it easier or more difficult to make connections and find a job? Explain.
    12·1 answer
  • Which header provides functions that deal with exceptional conditions?
    13·1 answer
  • With his assembly lines, Henry Ford improved what process? A. computer management B. just-in-time management C. Bessemer process
    5·1 answer
  • How many bits does it take to represent the values from 0 to 255?
    9·1 answer
  • What are the advantages of using an external style sheet?
    9·1 answer
  • Which two pieces of information must be provided when saving a file for the first time in Wordpad?____.
    8·1 answer
  • How can a signature be added to an email message? Check all that apply.
    10·2 answers
  • In Scheme, the form (symbol-length? 'James) will return: Group of answer choices 0 5 6 error message
    11·1 answer
  • Im a beginner programmer. what languages should i learn and how do i get better
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!