10
Question 3: (2 marks)
The given file Q3.py already contains statements to input data for the list and a variable x. You should write statements to print out the average of elements that are divisible by x in the list.
Notes:
- You can create new functions if you see it is necessary
- Do not edit given statements in the main function
- The output value is formatted in two decimal places
Sample input and output:
Input:
Enter the number of elements:5
List: 3 2 5 7 6
Enter x = 3
After processing: (3+6)/2=4.50
Output for marking:
OUTPUT:
4.50
ER
Question 4: (3 marks)
The given file Q4.py already contains statements to input a string named str. You should write statements to sum characters are digits in string str.
Notes:
- Do not edit given statements in the main function.
- You can create new functions if you see it is necessary.
Sample input and output:
Input: PFP191 PE SU23
After processing: S = 1+9+1+2+3=16
Output for marking:
OUTPUT:
16
Zoom
+ 80%
Close