MFSS 2019 P2
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesName: ______________________________ ( ) Class: _______ MONTFORT SECONDARY SCHOOL PRELIMINARY EXAMINATION 2019 Secondary 4 Express COMPUTING Paper 2 (Lab-based) 11.30 am 7155/02 2 Sep 2019 (Mon) 2 hours 30 minutes Additional Materials: Electronic version of VEHICLES.xlxs data file Electronic version of VOWELS.py file Electronic version of SORTNUMBER.py file Insert Quick Reference Glossary attached as ANNEX A READ THESE INSTRUCTIONS FIRST Do not open this booklet until you are told to do so. Write your name, index number and class in the spaces provided at the top of this page. Write in dark blue or black pen. Answer all questions. All tasks must be done in the computer laboratory. You are not allowed to bring in or take out any pieces of work or materials on paper or electronic media or in any other form. Programs are to be written in Python. Save your work using the file name given in the question as and when necessary. The number of marks is given in brackets [ ] at the end of each question or part question. The total marks for this paper is 50. For Examiner’s Use Total 50
2 This document consists of 6 printed pages. Setter: Mr Wong Teck Piaw, Mr Ricky Tan Task 1 A company uses spreadsheet software to record the list of vehicles they are interested in purchasing. You are required to finish setting up the spreadsheet to record the loan amount and monthly installment for each vehicle. Open the file VEHICLES.xlsx. You will see the following data. Save the file as MYVEHICLES_<your name>_<your class>_<index number>.xlsx 1 In cell B20 enter a formula to count the number of vehicles listed. [1] 2 In cell B21 enter a formula to calculate the range of prices of vehicles listed. [1] 3 Enter a formula to calculate the loan amount for each vehicle and use it to complete the Loan Amount column. The loan amount is the balance after the downpayment is paid. [1] 4 Use an appropriate function to search for the Interest Rate per Year in the Rates table and use it to complete the Interest Rate (p.a.) column. [2] 5 Enter a formula to calculate the monthly instalment for each vehicle and use it to complete the Monthly Instalment column. [2]
3 6 The company now decides to consider all BrandA vehicles only. Use a conditional statement to identify all BrandA vehicles and put Yes in the Shortlist column. Otherwise put No in the Shortlist column. Save and close your file. [3] Task 2 The alphabet is made up of 26 letters, 5 of which are vowels (a, e, i, o, u) and the rest of which are consonants. The following program accepts the input string 'computing' and prints out the number of occurrences for vowels in the string, and the consonants in the string. vowel_num = 0 consonants = '' for letter in 'computing': if letter in ['a','e','i','o','u']: vowel_num += 1 else: consonants += letter print('Number of Vowels: ',vowel_num) print('Consonants: ',consonants) Open the file VOWELS.py Save the file as MYVOWELS_<your name>_<your class>_<index number>.py 7 Edit the program so that it: (a) Also accepts vowels in capital letters (i.e. ‘A’, ‘E’, ‘I’, ‘O’ and ‘U’). (b) Asks the user for a string input and processes it instead of using the string 'computing'. (c) Only allows string with length of less than 10 characters. Otherwise, it displays the text “String must be less than 10 characters” and prompts for the string input again. (d) Displays the length of the consonants at the last line of the program output. Save your program. [1] [2] [3] [1] 8 Save your program as VARVOWELS_<your name>_<your class>_<index number>.py Edit your program so that it works for any number of string inputs. Save your program. [3]
4
5 Task 3 The following program should read integers from the user one at a time until a “q” is entered. Once all of the integers have been read, the program should display: ● All of the negative integers, followed by all of the zeros, followed by all of the positive integers. ● The numbers should be printed in the same order that they were entered by the user. ● Each number should be printed on its own line. There are several syntax errors and logical errors in the program. negative = [ ] positives = [ ] zeros = [0] number = input("Enter an integer(enter q to quit): ) while number =! "q": num = str(number) if num < 0: negatives.append(num) elif num >= 0: positives.append(number) else zeros = zeros + 1 number = input("Enter an integer(enter q to quit): ") print("The numbers were: ") for n in negatives: print(n) for z in zeros: print(z) for p in positives: print(positives[p]) Open the file SORTNUMBER.py Save the file as SORTNUMBER _<your name>_<class>_<index number>.py 9 Identify and correct the errors in the program so that it works correctly according to the rules above. Save your program. [10]
6 Task 4 You have been asked to write a program to classify and calculate the areas of 6 triangles. The program should allow you to: ● Enter data in the format a,b,c where a, b, c are lengths of the three sides of a triangle An example is 11,15,20. ● Only allow data entry of integers in the range 10-99 (inclusive). ● Perform data validation to ensure that the Triangle Inequality Theorem holds: The Triangle Inequality Theorem states that the sum of the lengths of any 2 sides of a triangle must be greater than the length of the third side. ● Repeat this for a total of six triangles. ● Classify each triangle, and calculate the corresponding area rounded to 2 decimal places. ● The classification for the types of triangles is given below: Classification Characteristics Equilateral all sides are of equal lengths Isosceles only 2 sides are of equal lengths Right Angled satisfies Pythagorean Theorem. i.e 𝑎!+𝑏!=𝑐! Scalene all 3 sides are of different lengths ● The Heron’s formula to find the area of a triangle given the lengths of all sides is: 𝐴𝑟𝑒𝑎= *𝑠(𝑠−𝑎)(𝑠−𝑏)(𝑠−𝑐), where 𝑠 is 𝑠=!"#"$% ● Display this on the screen. Your output must look like this: 11,15,20 Scalene 81.39 30,40,50 Right Angled 600.0 33,66,66 Isosceles 1054.42 46,30,21 Scalene 248.37 27,27,27 Equilateral 315.67 24,26,10 Right Angled 120.0 10 Write your program and test that it works. Save your program as TRI_<your name>_<your class>_<index number>.py [10] 11 When your program is working, use the following test data to show your test results: 11,15,20 30,40,50 33,66,66 46,30,21 27,27,27 24,26,10 Take a screen shot of your results and save it as TRIRESULTS_<your name>_<your class>_<index number> Save your file in either .png or .jpg format. [5]
7 12 Save your program as TRIAREAS_<your name>_<your class>_<index number>.py Extend your program to: ● Identify the largest triangle and add the label “(Largest)” beside the output. ● Calculate the average area of the triangles rounded to 2 decimal places, and output the average area at the last line of the program. Your output should look like this: 11,15,20 Scalene 81.39 30,40,50 Right Angled 600.0 33,66,66 Isosceles 1054.42 (Largest) 46,30,21 Scalene 248.37 27,27,27 Equilateral 315.67 24,26,10 Right Angled 120.0 Average area: 403.31 Save your program. [3] 13 Save your program as VARTRI_<your name>_<your class>_<index number>.py Extend your program to work for any number of triangles. Save your program. [2] End of Paper
Content continues in the PDF. Download PDF
Related notes
- SST (for revision practice) 2024 S3 Computing EOY P2 QP_FinalExam Papers · 2024
- Computing o level notes Notes/Practices · 2023
- BVSS Prelim P1 CPExam Papers · 2024
- BVSS Prelim P1 MSExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices
- SST 2024 Prelim Paper 1 [revised for 2025] Exam Papers · 2024
- SST 2024 Prelim Paper 1 Ans [revised for 2025] Exam Papers · 2024
- [Notes for Computing] Heavily Compressed TextbookNotes/Practices · 2025
- [Notes for Computing] All Definitions/ TermsNotes/Practices · 2025
- (Notes) Heavily Compressed TextbookNotes/Practices · 2025
- See all Computing notes

