-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoop
More file actions
48 lines (37 loc) · 1.39 KB
/
Copy pathLoop
File metadata and controls
48 lines (37 loc) · 1.39 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
#Write a for loop the prints out all the element between -5 and 5 using the range function
for i in range(-5,6):
print(i)
#Print the elements of the following list: Genres=[ 'rock', 'R&B', 'Soundtrack', 'R&B', 'soul', 'pop'] Make sure you follow Python conventions.
Genres=[ 'rock', 'R&B', 'Soundtrack', 'R&B', 'soul', 'pop']
for Genre in Genres:
print(Genre)
#Write a for loop that prints out the following list: squares=['red', 'yellow', 'green', 'purple', 'blue']
squares=['red', 'yellow', 'green', 'purple', 'blue']
for square in squares:
print(square)
#Write a while loop to display the values of the Rating of an album playlist stored in the list PlayListRatings.
#If the score is less than 6, exit the loop.
#The list PlayListRatings is given by: PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
#option 1:
i=0
Rating=0
while(PlayListRatings[i]>6):
Rating=PlayListRatings[i]
i=i+1
print(Rating)
#option 2
i = 1
Rating = PlayListRatings[0]
while(Rating >= 6):
print(Rating)
Rating = PlayListRatings[i]
i = i + 1
#Write a while loop to copy the strings 'orange' of the list squares to the list new_squares.
#Stop and exit the loop if the value on the list is not 'orange':
squares = ['orange', 'orange', 'purple', 'blue ', 'orange']
new_squares = []
i = 0
while(squares[i] == 'orange'):
new_squares.append(squares[i])
i = i + 1
print (new_squares)