forked from mouredev/Hello-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_functions.py
More file actions
60 lines (39 loc) · 1.4 KB
/
10_functions.py
File metadata and controls
60 lines (39 loc) · 1.4 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
# Clase 6 (08/09/22) en directo desde Twitch: https://www.twitch.tv/videos/1585369113
### Functions ###
# Definición
def my_function ():
print("Esto es una función")
my_function()
my_function()
my_function()
# Función con parámetros de entrada/argumentos
def sum_two_values (first_value: int, second_value):
print(first_value + second_value)
sum_two_values(5, 7)
sum_two_values(54754, 71231)
sum_two_values("5", "7")
sum_two_values(1.4, 5.2)
# Función con parámetros de entrada/argumentos y retorno
def sum_two_values_with_return (first_value, second_value):
my_sum = first_value + second_value
return my_sum
my_result = sum_two_values(1.4, 5.2)
print(my_result)
my_result = sum_two_values_with_return(10, 5)
print(my_result)
# Función con parámetros de entrada/argumentos por clave
def print_name (name, surname):
print(f"{name} {surname}")
print_name(surname = "Moure", name = "Brais")
# Función con parámetros de entrada/argumentos por defecto
def print_name_with_default (name, surname, alias = "Sin alias"):
print(f"{name} {surname} {alias}")
print_name_with_default("Brais", "Moure")
print_name_with_default("Brais", "Moure", "MoureDev")
# Función con parámetros de entrada/argumentos arbitrarios
def print_upper_texts(*texts):
print(type(texts))
for text in texts:
print(text.upper())
print_upper_texts("Hola", "Python", "MoureDev")
print_upper_texts("Hola")