0
Python 3 Boolean logic
The question is: You need to create a program that outputs whether a store is Open or Closed, based on the hour and the day of the week. The store is open on all days from 10 to 21, except Saturday and Sunday. You need to take the hour and the day of the week as input. The day of the week is represented as an integer (1 for Monday, 2 for Tuesday, etc.) Sample Input: 15 4 Sample Output: Open Here is my code: hour = int(input()) day = int(input()) if ((day) > 0) and ((day) < 6): if ((hour) > 10) and ((hour) < 21): print("Open") else: print("Closed") (Help appreciated) (The issue is with test case 4 which is hidden)
5 Answers
+ 4
1) if hour is 10 it should be open, so use hour >= 10
2) if the day is in 1-5, but the hour not in 10-21 your code has no output
+ 4
The question says that the store is open from 10 to 21, which means it is open at 10 and 21 also right? In your code, you are checking if hour is *greater than* 10 and *smaller than* 21 and thus if hour is 10 or 21, it will output "Closed"
+ 2
Conal Mckeeman
I think Benjamin JĂŒrgens pointed out the correct thing with his 2nd point. Try fixing that
0
I have already tried >= 10 and <= 21 and it doesn't seem to work thanks for the feedback though
0
Yeah the second point is correct still working on fix though.