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]
2 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]2 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
I need some cool things to do with windows command prompt.
STatiana [176]
I programmed in batch before so I know a lot of things!

You can ping a website to test your latency.

ping google.com

I have a ton of tricks in cmd (Command Prompt). Message me if you want.





7 0
3 years ago
Write the logical Expression and Draw the Truth table for the <br> following questions
Alja [10]

The logical expressions are

  • (X NOR Y ) OR Z ⇒ (\bar X  \bar + \bar Y) + Z
  • (A NAND B) AND NOT C ⇒ (\bar A \bar \cdot\bar B) \cdot \bar C

<h3>How to determine the logical expressions?</h3>

<u>Logical expression 1</u>

X and Y are linked by the NOR gate.

So, we have:

X NOR Y

The X NOR Y is linked to Z by the OR gate.

So, we have:

(X NOR Y) OR Z

Hence, the logical expression is (X NOR Y ) OR Z ⇒ (\bar X  \bar + \bar Y) + Z

<u>Logical expression 2</u>

A and B are linked by the NAND gate.

So, we have:

A NAND B

The A NAND B is linked to C by the AND gate.

So, we have:

(A NAND B) AND C

Hence, the logical expression is (A NAND B) AND NOT C ⇒ (\bar A \bar \cdot\bar B) \cdot \bar C

See attachment for the truth tables

Read more about truth tables at:

brainly.com/question/27989881

#SPJ1

6 0
1 year ago
Which of the following statements invokes the GetDiscount function, passing it the contents of two Decimal variables named decSa
ryzh [129]

Answer:

c. decDiscount = GetDiscount(decSales, decRate)                                                                                                                          

Explanation:

Option a. is incorrect because it is using Call word which is not a valid way to invoke a function.

Similarly option b. is also incorrect because it uses Call word to invoke function GetDiscount() which is not a valid way to call a function and also it is passing it the contents of three variables decSales, decRate and decDiscount and as mentioned in the question only two parameters are to be passed to GetDiscount() function.

Option c. is correct as it invokes the function GetDiscount() and passes it the contents of two variables decSales and decRate and assigns this to a variable decDiscount. For example if the GetDiscount() method has to calculate the discount using decSales and decRate then the resultant value of this computation is assigned to decDiscount. So whatever this function returns or computers is assigned to and stored in decDiscount variable. So this is a valid way to invoke a method.

3 0
2 years ago
Which of the following keys moves the insertion point to the end of data in a cell?
IgorC [24]
C) End is the key that moves the insertion point to the end of data in a cell. 
5 0
3 years ago
Why am I constantly getting bombarded with brainly plus ads and how to fix this without paying for it?
Helga [31]

Answer:

there really is no way to fix it. I've tried everything everybody says sorry

8 0
3 years ago
Read 2 more answers
Other questions:
  • Operating system software allows you to use your fingers, a mouse or other pointing device to select screen controls, such as bu
    5·2 answers
  • Help plz
    5·1 answer
  • After reviewing the various types of network connections available, a client chooses a network connection that is considered to
    13·1 answer
  • Using a personal computer to produce high quality printed documents
    8·1 answer
  • Compressing a file is also called
    9·2 answers
  • A domain name is used to: *
    15·1 answer
  • What is the component on the motherboard that confirms all devices are in working order once the computer is turned on?
    13·1 answer
  • Do you remember your first 3D movie experience? What was the movie, what was the experience like, and why was it memorable? (If
    7·1 answer
  • write code that removes the first and last elements from a list stored in a variable named my_list. assume that the list has bee
    13·1 answer
  • Taking control of admin functionality and misusing sensitive data that are unauthorized to access are due to.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!