Name
I am not sure about it
Answer:
I will code in Javascript.
Preconditions:
The variables k, incompletes has been declared and initialized.
The variable nIncompletes contains the number of elements of incompletes.
The variable stududentID has been declared and initialized.
The variable numberOfIncompletes has been declared.
Script:
numberOfIncompletes = 0; <em>//initialize numberOfIncompletes</em>
for( k = 0; k < nIncompletes; k++) {
if(incompletes[k] == studentID){ <em>//if the element of array is equal to studentID</em>
numberOfIncompletes++; <em>//adds 1 to numberOfIncompletes</em>
}
}
Explanation:
The script uses a for loop to go through the entire array incompletes, comparing the k variable with nIncompletes and adding 1 on each pass.
Then inside the for, uses an if statement to compare if the actual element is equal to studentID, if equal adds 1 numberOfIncompletes.
Answer:
Answer explained below. Python language used
Explanation:
The size of the square is of size 10. So assuming zero indexing,
vertical side1 (column Index = 5): row index from 5 to 14
vertical side1 (column Index = 14): row index from 5 to 14
horizontal side1 (row Index = 5): column index from 5 to 14
horizontal side2 (row Index = 14): column index from 5 to 14
Note:
while indexing, data_new[a:b,c] denotes,
row index: a to b-1
column index: c
Similarly data_new[a,b:c] denotes,
row index: a
column index: b to c-1
<u>Code:
</u>
import matplotlib.pyplot as plt
import numpy as np
size_1 = 20
size_2 = 20
data_new = np.random.random((size_1,size_2))
data_new[5:15,5] = 4
data_new[5:15,14] = 4
data_new[5,5:15] = 4
data_new[14,5:15] = 4
fig = plt.figure(figsize=(10,10))
plt.imshow(data_new)
plt.colorbar()
plt.show()
Basic input/output system