You need to create a program that outputs whether a store is Open or Closed, based on hour and day | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

You need to create a program that outputs whether a store is Open or Closed, based on hour and day

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.) https://code.sololearn.com/c3C1hd9ky5ft/?ref=app https://code.sololearn.com/c3C1hd9ky5ft/?ref=app

24th Dec 2020, 4:44 AM
Puneetha Akula
Puneetha Akula - avatar
19 Answers
+ 6
#You can use "or" operator to check the hours hour = int(input()) day = int(input()) if ((hour<10 or hour>21) or (day>= 6)): print('Closed') else: print('Open')
24th Dec 2020, 5:31 AM
Simba
Simba - avatar
+ 3
hour, day = int(input()), int(input()) print("Open" if 10 <= hour < 21 and day < 6 else "Closed")
24th Dec 2020, 5:41 AM
David Ashton
David Ashton - avatar
+ 3
hour = int(input()) day = int(input()) if (hour>=10) and (hour<=21) and (day<=5): print("Open") else: print("Closed")
18th May 2021, 2:41 AM
Mohammed Ebrahim
Mohammed Ebrahim - avatar
+ 2
hour = int(input()) day = int(input()) # your code goes here hours = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] days = [1, 2, 3, 4, 5] def store(hour, day): if hour in hours and day in days: print("Open") else: print("Closed") store(hour, day)
16th Sep 2021, 12:46 PM
David Danso
David Danso - avatar
+ 1
If you did that, you would have realized that your logic makes no sense. "hour<10 and hour>21" will ALWAYS be false. You simply cannot have an integer which is smaller than 10 and bigger than 21 at the same time.
24th Dec 2020, 5:13 AM
Jeremy
Jeremy - avatar
0
Tell me....where I did mistake...Code is not working for some test cases
24th Dec 2020, 4:46 AM
Puneetha Akula
Puneetha Akula - avatar
0
The first part of your condition always evaluates to 'false', check your operstors. The second part evaluates to day >= 6. Again check your operators "6 or 7" will be just 6
24th Dec 2020, 4:53 AM
Jeremy
Jeremy - avatar
0
Yah, I already do that but I had failed in another test case.
24th Dec 2020, 5:05 AM
Puneetha Akula
Puneetha Akula - avatar
0
@Puneetha Akula , thank you for sharing your solution! In my initial attempt of this question, I wrote the code below, which turned out to be wrong (or at least half right...lol). Could someone kindly elaborate on why my code is wrong? I know the answer to this question has already been provided. I just want to have a better understanding. hour = int(input()) day = int(input()) if ((hour >=10 or hour <=21) or (day >= 1 or day <= 5)): print("Open") else: print("Closed")
4th Jan 2021, 8:12 AM
Ima
0
a=int(input("enter the day of the week you want to visit")) b=int(input("enter the time you want to visit")) if (1<a<=5) and(10<b<21): print("open") else : print ("closed")
4th Apr 2021, 9:19 AM
shourya ranjan
shourya ranjan - avatar
0
hour = int(input()) day = int(input()) if (hour>=10) and (hour<=21) and (day<=5): print("Open") else: print("Closed")
18th May 2021, 2:40 AM
Mohammed Ebrahim
Mohammed Ebrahim - avatar
0
hour = int(input()) day = int(input()) if (hour == 10 or hour <= 21) and (day == 1 or day <= 5 ): print("Open") else: print("Closed")
21st May 2021, 2:58 AM
Alejandro
Alejandro - avatar
0
hour = int(input()) day = int(input()) if (hour == 10 or hour <= 21) and (day == 1 or day <= 5 ): print("Open") else: print("Closed") This passes all the tests however it is still wrong. If the code tested for 9AM it should fail but passes because the OR hour is <=21.
31st May 2021, 3:00 PM
Thomas Swinney
Thomas Swinney - avatar
0
hour = int(input()) day = int(input()) if hour >= 10 and hour <= 21 and day <=5: print("Open") else: print("Closed")
17th Jul 2021, 12:40 AM
Jose E. Turcios Lovo
0
hour=int(input('Enter the hour: ')) print('Enter day in following number: \n 1 for Monday \n 2 for Tuesday \n 3 for Wednesday \n 4 for Thursday \n 5 for Friday \n 6 for Saturday \n 7 for Sunday') day=int(input('Enter the day you want: ')) if(day!=6 and day!=7): if(hour>=10 and hour<=21): print('opened') else: print('closed') else: print('closed')
21st Dec 2021, 4:49 PM
SANVIKA
0
hour = int(input()) day = int(input()) if hour >= 10 and hour <=21 and day >=1 and day <=5: print("Open") else: print("Closed")
8th Jan 2022, 1:39 PM
Ihor Princ
Ihor Princ - avatar
0
I cant solve it
17th Jan 2022, 9:00 AM
Cesar Diaz
- 1
hour = int(input()) day = int(input()) if (hour >= 10 and hour <= 21) and (day >= 1 and day <= 5): print("Open") else: print("Closed") This would be the most correct answer because all possible inputs correctly output.
31st May 2021, 3:06 PM
Thomas Swinney
Thomas Swinney - avatar
- 9
SoloLearn, where you don't learn anything because people give you the correct answer instead of actually helping. Lmao
24th Dec 2020, 5:44 AM
Jeremy
Jeremy - avatar