0% found this document useful (0 votes)
17 views2 pages

T5 Exercises Arrays

The document provides examples of 2D array exercises, including printing student exam scores from a 2D array, counting the number of times the number 8 appears in exam grades, and converting student marks data into a 2D array to calculate overall averages, individual student and assessment averages, and student grades based on boundaries. It also includes exercises to generate a 2D array based on row and column inputs and create a noughts and crosses game using 2D numpy arrays.

Uploaded by

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

T5 Exercises Arrays

The document provides examples of 2D array exercises, including printing student exam scores from a 2D array, counting the number of times the number 8 appears in exam grades, and converting student marks data into a 2D array to calculate overall averages, individual student and assessment averages, and student grades based on boundaries. It also includes exercises to generate a 2D array based on row and column inputs and create a noughts and crosses game using 2D numpy arrays.

Uploaded by

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

2D ARRAY EXERCISES

1. For the following programs, state the purpose and output given the following data:
Scores=
[[98, 68, 65, 73, 67],
[77, 77, 88, 78, 90],
[53, 63, 74, 85, 72],
[77, 77, 68, 78, 91],
[88, 86, 90, 56, 81]]
STUDENT=0
EXAM=0
TCOUNTER=0
a. loop STUDENT from 0 to 4
output STUDENT+1, “Student”
loop EXAM from 0 to 4
output “----”, “Exam ”, EXAM+1, Scores[STUDENT][EXAM]
end loop
end loop
b. loop STUDENT from 0 to 4
output STUDENT+1, “Student”
loop EXAM from 0 to 4
if (Scores[STUDENT][EXAM] mod 10 = 5) then
output “----”, “Exam ”, EXAM+1, Scores[STUDENT][EXAM]
end if
end loop
end loop
c. loop STUDENT from 0 to 4
output STUDENT+1, “Student”
loop EXAM from 0 to 4
COUNTER=0
X= Scores[STUDENT][EXAM]
loop while X>0
if (X mod 10 = 8) then
COUNTER=COUNTER+1
TCOUNTER=TCOUNTER+1
end if
X=div(X,10)
end while
output “The grade of exam ”, EXAM+1, “has ”, COUNTER,
“eight(s)”
end loop
end loop
output “A total of ”, TCOUNTER, “eights appear in all grades”
2. A teacher has decided to use a 2D array to store the marks for one of their classes. The grade book
takes the following form:
i) Marksbook Test 1 Test 2 Test 3 Test 4 Test 5
ii) Student A 67% 50% 93% 83% 43%
iii) Student B 70% 52% 96% 85% 48%
iv) Student C 90% 81% 100% 93% 68%
v) Student D 55% 32% 71% 72% 58%
vi) Student E 60% 47% 65% 74% 61%
b. Convert the above into a suitable 2D array
c. Write pseudocode to determine the following:
i) Determine the overall average mark
ii) Determine the average mark for each individual student
iii) Determine the average mark for each individual assessment
iv) Given the following grade boundaries, determine the grade for each student: A = 85%, B
= 70%, C = 55%, D = 40%, F < 40%
d. Write code In python for this program.
3. Write a Python program that takes two digits m (row) and n (column) as input and generates a
two-dimensional array where the element value in the i-th row and j-th column of the array is i*j.
4. Research the numpy array functions. Write a game of noughts and crosses in python using 2D
arrays.

You might also like