Question

Create a new program in Mu and save it as ps2.3.3.py Take the code below and...

Create a new program in Mu and save it as ps2.3.3.py

  • Take the code below and fix it as indicated in the comments:

  • busy = True
    hungry = False
    tired = True
    stressed = False
    
    # You may modify the lines of code above, but don't move them!
    # Your code should work with different values for the variables.
    
    # Logical operators get more complex when we start using them
    # with the results of other logical operators. So, let's try
    # it out!
    #
    # Using the variables above, we want to assess whether the
    # person is happy, sad, bored, confused, or anxious.
    #
    # - The person is happy if they're busy but not stressed.
    # - The person is sad if they're either hungry or tired.
    # - The person is confused if they're both happy and sad.
    # - The person is bored if they're neither happy, sad,
    #   nor busy.
    # - The person is anxious if they're neither happy nor sad,
    #   but they are stressed.
    #
    # Add code below whose output will list whether each of these
    # emotions is true or false. For example, with the original
    # values of the variables above, this would print:
    #
    # Happy: True
    # Sad: True
    # Confused: True
    # Bored: False
    # Anxious: False
    
    # Add your code here!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

busy = True
hungry = True
tired = True
stressed = True
print(30*"=")
print("Busy:", busy)
print("Hungry:", hungry)
print("Tired:", tired)
print("Stressed:", stressed)
print(30*"=")
# Using the variables above, we want to assess whether the
# person is happy, sad, bored, confused, or anxious.
#
# - The person is happy if they're busy but not stressed.
# - The person is sad if they're either hungry or tired.
# - The person is confused if they're both happy and sad.
# - The person is bored if they're neither happy, sad,
#   nor busy.
# - The person is anxious if they're neither happy nor sad,
#   but they are stressed.

happy = (busy and not stressed)
sad = (hungry or tired)
confused = (happy and sad)
bored = (not happy and not sad and not busy)
anxious = (not happy and not sad and stressed)


print("Happy:", happy)
print("Sad:", sad)
print("Confused:", confused)
print("Bored:", bored)
print("Anxious:", anxious)

Code Screenshot:

Output:

I have entered different values of busy, hungry, tired and stressed to test the values of happy, sad, confused, bored and anxious. And all of thier results are in the output screenshot.

Thank you! Hit like if you like my work.

Add a comment
Know the answer?
Add Answer to:
Create a new program in Mu and save it as ps2.3.3.py Take the code below and...
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
  • Create a new program in Mu and save it as ps3.3.1.py and take the code below...

    Create a new program in Mu and save it as ps3.3.1.py and take the code below and fix it as indicated in the comments: mystery_int = 50 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Write a for loop that prints every third number from 1 to # mystery_int inclusive (meaning that if mystery_int is 7, it #...

  • Create a new program in Mu and save it as ps3.2.2.py and take the code below...

    Create a new program in Mu and save it as ps3.2.2.py and take the code below and fix it as indicated in the comments: egg = True milk = True butter = True flour = True # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Imagine you're deciding what you want to cook. The boolean # variables...

  • Create a new program in Mu and save it as ps2.4.3.py Take the code below and...

    Create a new program in Mu and save it as ps2.4.3.py Take the code below and fix it as indicated in the comments: Level = 50 Attack = 125 Defense = 110 Power = 60 Modifier = 1 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # In the Pokemon game franchise, damage is calculated using this formula found here: # https://bulbapedia.bulbagarden.net/wiki/Damage # #...

  • Create a new program in Mu and save it as ps2.4.1.py Take the code below and...

    Create a new program in Mu and save it as ps2.4.1.py Take the code below and fix it as indicated in the comments: dividend = 7 divisor = 3 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # The variables above create a dividend and a divisor. Add # some code below that will print the quotient and remainder # of performing this operation....

  • Create a new program in Mu and save it as ps3.3.3.py and take the code below...

    Create a new program in Mu and save it as ps3.3.3.py and take the code below and fix it as indicated in the comments: mystery_int = 46 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Use a while loop to create a countdown from mystery_int to # 0. Count down by 3s: if mystery_int is 46, then you...

  • Create a new program in Mu and save it as ps3.2.1.py and take the code below...

    Create a new program in Mu and save it as ps3.2.1.py and take the code below and fix it as indicated in the comments: hour = 3 minute = 45 # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Around Georgia Tech, there are plenty of places to get a # late night bite to eat. However,...

  • Create a new program in Mu and save it as ps3.4.2.py and take the code below...

    Create a new program in Mu and save it as ps3.4.2.py and take the code below and fix it as indicated in the comments: # A year is considered a leap year if it abides by the # following rules: # # - Every 4th year IS a leap year, EXCEPT... # - Every 100th year is NOT a leap year, EXCEPT... # - Every 400th year IS a leap year. # # This starts at year 0. For example:...

  • Create a new program in Mu and save it as ps3.4.3.py and take the code below...

    Create a new program in Mu and save it as ps3.4.3.py and take the code below and fix it as indicated in the comments: # Consult this blood pressures chart: http://bit.ly/2CloACs # # Write a function called check_blood_pressure that takes two # parameters: a systolic blood pressure and a diastolic blood # pressure, in that order. Your function should return "Low", # "Ideal", "Pre-high", or "High" -- whichever corresponds to # the given systolic and diastolic blood pressure. # #...

  • Create a new program in Mu and save it as ps4.3.3.py and take the code below...

    Create a new program in Mu and save it as ps4.3.3.py and take the code below and fix it as indicated in the comments: # Imagine you're writing some code for an exercise tracker. # The tracker measures heart rate, and should display the # average heart rate from an exercise session. # # However, the tracker doesn't automatically know when the # exercise session began. It assumes the session starts the # first time it sees a heart rate...

  • Create a new program in Mu and save it as ps4.5.3.py and take the code below...

    Create a new program in Mu and save it as ps4.5.3.py and take the code below and fix it as indicated in the comments: # In the Pokemon video game series, every Pokemon has six # stats: HP, Attack, Defense, Special Attack, Special Defense, # and Speed. # # Write a function called total_stats that will take as input # a list of dictionaries. Each dictionary will have seven # key-value pairs: # # - name: a Pokemon's name #...

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
Active Questions
ADVERTISEMENT