-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path17-while.py
More file actions
56 lines (40 loc) · 1.16 KB
/
17-while.py
File metadata and controls
56 lines (40 loc) · 1.16 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
#LISTA DE FILMES
movieList = ["Star Wars", "Matrix", "Senhor dos Aneis", "Clube da Luta", "Forrest Gump"]
#1 Iterando uma lista de filmes usando o comando while
'''
index = 0
while index < len(movieList):
print(movieList[index])
index += 1
'''
'''
#2 Quando a condição for atendida o loop será encerrado
index = 0
while index < len(movieList):
if movieList[index] == "Clube da Luta":
break
print(movieList[index])
index += 1
'''
#3 Quando a condição for atendida, o loop vai para a próxima iteração, utilizando o comando continue
index = 0
while index < len(movieList):
if movieList[index] == "Senhor dos Aneis":
index += 1
continue
print(movieList[index])
index += 1
#4 Avaliação do filme utilizando while
movieName = input("Digite o nome do filme: ")
movieRating = int(input("Digite quantas avaliações deseja fazer"))
total = 0
count = 0
while count < movieRating :
note = float(input("Digite a nota para o filme:\n"))
total += note
count += 1
if movieRating > 0 :
average = total / movieRating
else:
tota = 0
print(f"Média de avaliação do filme {movieName} é {average:.2f}")