-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathfonctions_1.py
More file actions
105 lines (56 loc) · 1.67 KB
/
Copy pathfonctions_1.py
File metadata and controls
105 lines (56 loc) · 1.67 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
##############################
# Fonctions - Idées
##############################
##############################
# Activité 1 - Introduction aux fonctions
##############################
##################################################
## Question 1 ##
# Fonction sans paramètre, sans sortie
def affiche_table_de_7():
""" Affiche la table de 7 """
print("--- Table de 7 ---")
for i in range(1,11):
print(i,"x 7 =",str(i*7))
return
# Test
affiche_table_de_7()
##################################################
def affiche_bonjour():
""" Dit bonjour """
prenom = input("Comment t'appelles-tu ? ")
print("Bonjour",prenom)
return
# Test
affiche_bonjour()
##################################################
## Question 2 ##
# Fonction avec paramètre, sans sortie
def affiche_une_table(n):
""" Affiche la table de n """
print("--- Table de",n,"---")
for i in range(1,11):
print(i,"x",n,"=",str(i*n))
return
# Test
affiche_une_table(5)
##################################################
def affiche_salutation(formule):
""" Dit bonjour, bonsoir, au revoir... """
prenom = input("Comment t'appelles-tu ? ")
print(formule,prenom)
return
# Test
affiche_salutation("Coucou")
##################################################
## Question 3 ##
# Fonction sans paramètre, avec sortie
def demande_prenom_nom():
""" Demande et renvoie le prénom et le nom """
prenom = input("Quel est ton prénom ? ")
nom = input("Quel est ton nom ? ")
nom_complet = prenom + " " + nom.upper()
return nom_complet
# Test
identite = demande_prenom_nom()
print("Identité :",identite)