4
4
5
5
# Definición
6
6
7
- def my_function ():
7
+ def my_function ():
8
8
print ("Esto es una función" )
9
9
10
+
10
11
my_function ()
11
12
my_function ()
12
13
my_function ()
13
14
14
15
# Función con parámetros de entrada/argumentos
15
16
16
- def sum_two_values (first_value : int , second_value ):
17
+
18
+ def sum_two_values (first_value : int , second_value ):
17
19
print (first_value + second_value )
18
20
21
+
19
22
sum_two_values (5 , 7 )
20
23
sum_two_values (54754 , 71231 )
21
24
sum_two_values ("5" , "7" )
22
25
sum_two_values (1.4 , 5.2 )
23
26
24
27
# Función con parámetros de entrada/argumentos y retorno
25
28
26
- def sum_two_values_with_return (first_value , second_value ):
29
+
30
+ def sum_two_values_with_return (first_value , second_value ):
27
31
my_sum = first_value + second_value
28
32
return my_sum
29
33
34
+
30
35
my_result = sum_two_values (1.4 , 5.2 )
31
36
print (my_result )
32
37
@@ -35,26 +40,31 @@ def sum_two_values_with_return (first_value, second_value):
35
40
36
41
# Función con parámetros de entrada/argumentos por clave
37
42
38
- def print_name (name , surname ):
43
+
44
+ def print_name (name , surname ):
39
45
print (f"{ name } { surname } " )
40
46
41
- print_name (surname = "Moure" , name = "Brais" )
47
+
48
+ print_name (surname = "Moure" , name = "Brais" )
42
49
43
50
# Función con parámetros de entrada/argumentos por defecto
44
51
45
- def print_name_with_default (name , surname , alias = "Sin alias" ):
52
+
53
+ def print_name_with_default (name , surname , alias = "Sin alias" ):
46
54
print (f"{ name } { surname } { alias } " )
47
55
56
+
48
57
print_name_with_default ("Brais" , "Moure" )
49
58
print_name_with_default ("Brais" , "Moure" , "MoureDev" )
50
59
51
60
# Función con parámetros de entrada/argumentos arbitrarios
52
61
62
+
53
63
def print_upper_texts (* texts ):
54
64
print (type (texts ))
55
65
for text in texts :
56
66
print (text .upper ())
57
67
58
68
59
69
print_upper_texts ("Hola" , "Python" , "MoureDev" )
60
- print_upper_texts ("Hola" )
70
+ print_upper_texts ("Hola" )
0 commit comments