From 31c68651b718e4c3e507da0cb057e37c8f681c00 Mon Sep 17 00:00:00 2001 From: Dipanshu Date: Sat, 3 Oct 2020 15:21:01 +0530 Subject: [PATCH 1/3] tell whether its day or night --- dayOrNight.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 dayOrNight.py diff --git a/dayOrNight.py b/dayOrNight.py new file mode 100644 index 0000000..9f14039 --- /dev/null +++ b/dayOrNight.py @@ -0,0 +1,8 @@ +from datetime import datetime as dt + +hour = int(dt.now().strftime("%H")) + +if(hour >= 19): + print("Night") +else: + print("Day") \ No newline at end of file From 7ae28d4d508e2d02f8bb144e398b7d7bdfd9bfad Mon Sep 17 00:00:00 2001 From: Dipanshu Date: Sat, 3 Oct 2020 15:24:44 +0530 Subject: [PATCH 2/3] added something more --- dayOrNight.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dayOrNight.py b/dayOrNight.py index 9f14039..b280d90 100644 --- a/dayOrNight.py +++ b/dayOrNight.py @@ -1,8 +1,9 @@ from datetime import datetime as dt hour = int(dt.now().strftime("%H")) +time = dt.now().strftime("%H:%M:%S") if(hour >= 19): - print("Night") + print("time is",time,".Thus it is","Night") else: - print("Day") \ No newline at end of file + print("time is",time,".Thus it is","Day") \ No newline at end of file From 98139f36ff322d4060f68be02a8473a2661a990c Mon Sep 17 00:00:00 2001 From: ninja Date: Sat, 3 Oct 2020 15:30:49 +0530 Subject: [PATCH 3/3] added decision according to user --- dayOrNight.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dayOrNight.py b/dayOrNight.py index b280d90..59a8838 100644 --- a/dayOrNight.py +++ b/dayOrNight.py @@ -3,7 +3,12 @@ hour = int(dt.now().strftime("%H")) time = dt.now().strftime("%H:%M:%S") -if(hour >= 19): +yourDivider = int(input("After what hour(24 Hour system) you prefer Night: ")) +while not(1<=yourDivider<=23): + print("Please enter a valid Time when your night starts") + yourDivider = int(input("After what hour(24 Hour system) you prefer Night: ")) + +if(hour >= yourDivider): print("time is",time,".Thus it is","Night") else: print("time is",time,".Thus it is","Day") \ No newline at end of file