0% found this document useful (0 votes)
6 views3 pages

Cs 1

The document contains three activities involving programming. Activity 17 calculates the highest, lowest, and average marks from a 2D array of scores. Activity 18 identifies the highest scores for different levels from a list of player scores, while Activity 19 allows users to enter and search for album details in a collection.

Uploaded by

A Boi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Cs 1

The document contains three activities involving programming. Activity 17 calculates the highest, lowest, and average marks from a 2D array of scores. Activity 18 identifies the highest scores for different levels from a list of player scores, while Activity 19 allows users to enter and search for album details in a collection.

Uploaded by

A Boi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Activity 17:

array = [[80,59,34,89],[31,11,47,64],[29,56,13,91],[55,61,48,0],[75,78,81,91]]

highest = array[0][0]

lowest = array[0][0]

total = 0

count = 0

for row in array:

for column in row:

total += column

count += 1

if column > highest:

highest = column

elif column < lowest:

lowest = column

print(f"The highest mark is {highest}.")

print(f"The lowest mark is {lowest}.")

print("The average mark is", total / count)


Activity 18:
scores = [["Alexa", 1, 19],["Seema", 1, 29], ["Seema", 2, 44],["Lois", 1 , 10],["Alexis", 2, 17],["Alexis", 3,
36],["Dion", 1, 23],["Emma", 1, 27],["Emma", 2, 48]]

list1_HighScore = 0

list1_HighPlayer = ""

list2_HighScore = 0

list2_HighPlayer = ""

list3_HighScore = 0

list3_HighPlayer = ""

for row in scores:

player = row[0]

level = row[1]

score = row[2]

if level == 1 and score > list1_HighScore:

list1_HighScore = score

list1_HighPlayer = player

elif level == 2 and score > list2_HighScore:

list2_HighScore = score

list2_HighPlayer = player

elif level == 3 and score > list3_HighScore:

list3_HighScore = score

list3_HighPlayer = player

print(f"The highest score in level 1 was {list1_HighScore} which was achieved by {list1_HighPlayer}")

print(f"The highest score in level 2 was {list2_HighScore} which was achieved by {list2_HighPlayer}")

print(f"The highest score in level 3 was {list3_HighScore} which was achieved by {list3_HighPlayer}")

Activity 19:
A) String
B) String
C) Integer
D) String
collection = [["Where Rivers Meet", "Z Rahman", 2008, "World"],["Best OF cat Stevens", "C
Stevens",2002,"Instrumental"],["Blessing","J Rutter",2012,"Classical"]]

yes = "y"

while yes == "y":

while True:

choice = input("Press e to enter details of a new album, or s to search for an album.")

if choice == "e" or choice == "s":

break

if choice =="e":

new = []

album = input("Enter the name of the album: ")

artist = input("Enter the name of the artist: ")

year = int(input("Enter the year of release: "))

genre = input("Enter the name of the genre: ")

new = [album, artist, year, genre]

collection.append(new)

else:

search = input("Enter the title of the album: ")

found = False

index = 0

while found == False and index <= len(collection)-1:

if collection[index][0] == search:

print("Artist: ", collection[index][1], "\nYear of release: ", collection[index][2])

found = True

else:

index = index + 1

if found == False:

print("This album is not in your list")

yes = input("Press 'y' if you want another go.")

You might also like