Question

We're trying to decide how many snacks we can afford to buy at the movies. We've...

We're trying to decide how many snacks we can afford to buy at the movies. We've been given the cost of the snacks and the amount of money we have. Now, we need to determine what we can afford to buy.

  1. Beneath each commented question, write an if statement which uses the correct comparison / relational operator
  2. You should use the print function to match the output under Desired Output.
  3. candy = 5
    soda = 5
    popcorn = 7

    money = 13

    # Can we buy soda and candy?

    # Can we buy soda and popcorn?

    # Can we buy all three?

  4. Desired output:

    You can buy soda and candy
    You can buy soda and popcorn
    You cannot buy soda and popcorn
0 0
Add a comment Improve this question Transcribed image text
Answer #1
candy = 5
soda = 5
popcorn = 7

money = 13

if soda + candy <= money:
    print("You can buy soda and candy")
else:
    print("You cannot buy soda and candy")

if soda + popcorn <= money:
    print("You can buy soda and popcorn")
else:
    print("You cannot buy soda and popcorn")

if soda + candy + popcorn <= money:
    print("You can buy soda and candy and popcorn")
else:
    print("You cannot buy soda and candy and popcorn")
Add a comment
Know the answer?
Add Answer to:
We're trying to decide how many snacks we can afford to buy at the movies. We've...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 9) Which of the following statements demonstrates that economic agents rationally respond to incentives? A) when...

    9) Which of the following statements demonstrates that economic agents rationally respond to incentives? A) when citrus fruits become more expensive, people don’t change their demand for it because we need vitamin C. B) Although it is cheaper to install security monitoring equipment than allowing burglaries to happen, most people don’t install it. C) When the price of iOS phones goes up, people may consider buying Android phones. D) More efficient batteries allow us to charge cell phones less often....

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • Please see the articles below… 1.  What is your opinion on the subject? 2.  Which ethical views (i.e.,...

    Please see the articles below… 1.  What is your opinion on the subject? 2.  Which ethical views (i.e., utilitarian view, moral rights view, justice view, practical view) you feel are being used by both sides of the argument (i.e., for and against downloading) to justify their positions? High Court Enters File-Sharing Spat; Justices Must Determine Software Providers' Liability For Copyright Violations by Anne Marie Squeo. Wall Street Journal. (Eastern edition). New York, N.Y.: Mar 30, 2005. pg. A.2 WASHINGTON -- The Supreme...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT