-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathP1_hello_word.py
More file actions
50 lines (35 loc) · 1.13 KB
/
P1_hello_word.py
File metadata and controls
50 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from datetime import datetime
def greet(nom):
date = datetime.now().date()
heure = datetime.now().hour
if 5 <= heure < 12:
t_greet = 'good morning'
if 12 <= heure < 18:
t_greet = 'good evening'
if 18 <= heure < 23:
t_greet = 'good nigth'
display_user(t_greet , nom , date)
def display_user(t_greet , nom , date):
print("===== HELLO WORD =====")
print(f"nous somme le {date},")
print(f"{t_greet} {nom}. Welcome in my first project")
def get_name():
tentative = 0
while True:
try:
nom = input("entrez votre nom : ").strip()
if nom ==" ":
raise Exception
if nom :
greet(nom)
break
else :
tentative += 1
print("erreur")
if tentative == 5:
print("vous avez atteint la tentative maximale")
break
except Exception:
print("ERROR: vous avez fait une erreur!!")
if __name__ == "__main__":
get_name()