+ 2
Время дня
how to write a program so that when entering time it knows that it is morning, afternoon, evening, night
16 Réponses
+ 9
Where is your attempt?
Post it here!
Edit:
Roman Vorko try this one.
It's easy way out.
https://code.sololearn.com/cj855Ay2dpnW/?ref=app
+ 2
In which language did you try to get it?
First of all you have to ask in this language what time is it.
+ 2
Roman Vorko Your welcome and congratulation.
+ 1
This code greet you after the time of day:
Приветствие по коду по времени суток:
https://code.sololearn.com/w2yqPJJ8ew39/?ref=app
+ 1
My example is in PHP.
+ 1
If you like you can see the solution in python live:
https://code.sololearn.com/cxwqoY7WZ2Tc/?ref=app
+ 1
Thanks 👍
+ 1
I wrote a little longer, but I corrected it too ...💪😁
0
👍😁✌️
0
constant: day_time (0--24)
MYTIME = int(input ("Enter time [0-24]:"))
# to do: create texts English, Russian , Hebrew
MYNIGHT = "Good night"
MYMORNING = "Good morning"
MYDAY = "Good day"
MYEVENING = "Good evening"
# To do: ask user Lenguage:
if MYTIME >=22 and MYTIME <8:
# night
out_sring = MYNIGHT
pass
elif MYTIME >=8 and MYTIME <12:
# morning
out_sring = MYMORNING
elif MYTIME >12 and MYTIME <=18:
# day
out_sring = MYDAY
else:
MYTIME <18 and MYTIME >22
out_sring = MYEVENING
print (out_sring)
0
I tried to write this, but it does not work correctly ...
0
In English
0
# constant: day_time (0--24)
MYTIME = int(input ("Enter time [0-24]:"))
# to do: create texts English, Russian , Hebrew
MYNIGHT = "Good night"
MYMORNING = "Good morning"
MYDAY = "Good day"
MYEVENING = "Good evening"
# To do: ask user Lenguage:
if MYTIME >=0 and MYTIME <8:
# night
out_sring = MYNIGHT
pass
elif MYTIME >=8 and MYTIME <12:
# morning
out_sring = MYMORNING
elif MYTIME>=12 and MYTIME <18:
# day
out_sring = MYDAY
elif MYTIME >=18 and MYTIME <22:
# evening
out_sring = MYEVENING
else:
out_sring = MYNIGHT
print (out_sring)
0
J