-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16-for.py
More file actions
34 lines (27 loc) · 911 Bytes
/
16-for.py
File metadata and controls
34 lines (27 loc) · 911 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
# Lista de Filmes
moviesList = ["Titanic", "The Godfather", "Inception", "Jurassic Park"]
# 1 - Iterando valores de uma lista
for movie in moviesList:
print(movie)
# 2 - Quando a condição for atendida, o loop será encerrado
for movie in moviesList:
if movie == "Inception":
break
print(movie)
# 3 - Quando a condição for atendida, o loop vai para próxima iteração
for movie in moviesList:
if movie == "Inception":
continue
print(movie)
# 4 - Avaliação do filme:
movieName = input("Digite o nome do filme:\n")
movieRating = int(input("Digite quantas avaliações deseja fazer:\n"))
total = 0
for i in range(movieRating):
note = float(input("Digite a nota para o filme:\n"))
total += note
if movieRating > 0:
average = total / movieRating
else:
average = 0
print(f"Média de avaliação do filme {movieName} é: {average:.2f}")