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

Hossam Abdelaziz - Y10_03_CT15_Homework

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

TOPIC 1: COMPUTATIONAL THINKING

Procedures

HOMEWORK FOR Y10-03-CT15

Name ____________________________________________ Date __________________

Question 1
A program is needed to analyse weekly statistics, which are stored in a list. A subprogram
within it should display the minimum value, the maximum value, and the average of all values
in the list.
Load ‘Hwk_Act1_Student’ into your programming environment.
Amend the code to add lines to:
 define a subprogram
 use a ‘for in list’ loop
 calculate the average
 call the subprogram.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.
1
TOPIC 1: COMPUTATIONAL THINKING

Procedures

Question 2
A program is needed to count the occurrences of a target item in different data structures.
Here are the data structures:

weeklyStats = [23, 15, 6, 5, 2, 0, 0,


19, 15, 7, 3, 0, 3, 3]
messages = ["Error", "OK", "OK", "Error", "Error", "OK", "OK",
"OK", "Error", "Error", "Error", "OK", "OK", "OK"]

Here is an example output: Error occurs 6 times.


Load ‘Hwk_Act2_Student’ into your programming environment.
Amend the code to meet these requirements:
 add a subprogram to count occurrences of an item
 the subprogram must take two input parameters, a list and a target
 the subprogram must display the result using string concatenation
 the main program must only have a single line to call the subprogram, using either
‘Error’ or ‘OK’ as the target.

Extension:
So far, your subprogram works with string targets.
Check if your program works with integer targets by adding another call to the subprogram.
Use 0 as the target argument.
If you program doesn’t work, then fix the error.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.
2
TOPIC 1: COMPUTATIONAL THINKING

Procedures

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.
3

You might also like