-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20-args_func.py
More file actions
36 lines (26 loc) · 880 Bytes
/
20-args_func.py
File metadata and controls
36 lines (26 loc) · 880 Bytes
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
#TRABALHANDO COM ARGUEMENTOS EM FUNÇÕES
#1 - Função para imprimir primeiro e último nome
def full_name(first_name, last_name):
print(f"Nome é: {first_name} {last_name}")
full_name("Mário", "Junior")
#2 - Função para somar números
def sum_numbers(a,b):
return a+b
print(f"O retorno da soma é {sum_numbers(10,20)}")
#3 - Função com parâmetro default
def address(coutry="Brasil"):
print(f"Eu moro em {coutry}")
address()
address("Espanha")
#4 - Função para avaliar filme
def movie_average(num_ratings, movie_name):
total = 0
for i in range(num_ratings):
note = float(input("Digite a nota para o filme:\n"))
total += note
if num_ratings > 0:
average = total / num_ratings
else:
average = 0
print(f"Média de avaliação do filme {movie_name} foi de {average:.2}")
movie_average(2, "O Máskara")