Python Forum
Need help with a homework problem on logical operators
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with a homework problem on logical operators
#2
The if statements for checking whether or not to go to lunch can be rearranged in this way
hungry = False
coworkers_going = False
brought_lunch = True

if brought_lunch and not coworkers_going:
    print(False)
elif coworkers_going and hungry:
    print(True)
elif not brought_lunch and hungry:
    print(True)
else:
    print(False)
Reply


Messages In This Thread
RE: Need help with a homework problem on logical operators - by SheeppOSU - Jun-28-2019, 12:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with a formula 1 kind of homework claroque 2 1,556 Jun-20-2023, 09:58 PM
Last Post: claroque
  Bakery Problem.. Can you Help My Homework Cemvrs 1 2,443 Jan-14-2022, 05:47 PM
Last Post: Yoriz
  logical error for loop mcgrim 8 3,824 May-25-2019, 01:38 AM
Last Post: michalmonday
  Functions with conditionals and comparison operators Drone4four 9 13,205 Jan-01-2019, 06:48 PM
Last Post: Drone4four
  Guessing game with comparison operators Drone4four 9 13,982 Dec-02-2018, 06:12 PM
Last Post: ichabod801
  Homework Problem csascott 1 2,337 Oct-27-2018, 04:44 AM
Last Post: scidam
  Homework Problem Travisbulls34 1 3,028 Sep-11-2018, 04:04 PM
Last Post: ichabod801
  Help with homework problem - iterating a function midnitetots12 4 3,617 Feb-21-2018, 10:51 PM
Last Post: nilamo
  Problem with a homework Samuelcu 2 2,909 Feb-03-2018, 01:39 PM
Last Post: Samuelcu
  2 logical problems Peter_EU 1 3,040 Oct-26-2017, 04:13 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020