1.3 - Pass or Fail

You have two parallel arrays: one holds pupil names and the other holds their scores. Print only the pupils who passed (score ≥ 14).

names = ["Jane", "John", "Jess", "Ava"]
scores = [12, 18, 15, 20]
Passes:
John - 18
Jess - 15
Ava - 20

 

set names to ["Jane", "John", "Jess", "Ava"]
set scores to [12, 18, 15, 20]

set pass_mark to 14

print "Passes:"

loop for length of names array
    if score at current position is greater than or equal to pass_mark
        print name and score at current position

 

names = ["Jane", "John", "Jess", "Ava"]
scores = [12, 18, 15, 20]

pass_mark = 14

print("Passes:")
for i in range(len(names)):
    if scores[i] >= pass_mark:
        print(names[i] + " - " + str(scores[i]))

# Parallel arrays: one stores pupil names, the other stores their scores
names = ["Jane", "John", "Jess", "Ava"]
scores = [12, 18, 15, 20]

# Set the pass mark
pass_mark = 14

# Display pupils who have passed
print("Passes:")

# Loop through each position in the arrays
for i in range(len(names)):
    # Check if the current pupil's score is greater than or equal to the pass mark
    if scores[i] >= pass_mark:
        # Print the pupil's name and score
        print(names[i] + " - " + str(scores[i]))

Extension

Print the pupils who passed (score ≥ 14) and the pupils who failed (score < 14).

Passes:
John - 18
Jess - 15
Ava - 20

Fails:
Jane - 12