ZHSS 7155 PRELIMS 2022 4E P2 MS
Uploaded by IDKWHYBUTIAM · 3 November 2024
Preview
Text from the first pagesMark Scheme and Answer Key Task 1 Mark Scheme 1. Accept only =SUM( ) to score 1 mark 2. Accept only =MAX( ) to score 1 mark 3. Accept only =ROUND(AVERAGE( ), 0) OR =SUM()/COUNT() to score 2 marks 4. Accept only =IF() with MAX() and LARGE() and " ", Correct Labels to score 4 marks 5. Check the Manage Rules for this setting, all correct entries to score 2 marks Task 2 Question 6 Award 1 mark for modification to program to allow for any number of fish to be entered. Typical strategy is to get user to input number of fish and use for loop. Award 1 mark for the suitable input message. Question 7 Award 1 mark for each combination of weight, length and output message accomplished. Question 8 Award 1 mark for correct naming of the list – fishweight and storage of weight data. Award 1 mark for correct naming of the list – fighlength and storage of length data. Award 1 mark for correctly outputting the average weight. Award 1 mark for correctly outputting the average length.
Task 3 [How I went about planting the bugs] 1 mark per error, indicated by red arrow.
CORRECTLY EDITED PROGRAM def mult(a, b): # multiply function using repeated addition algorithm # a and b must be integers, by using type casting a = int(a) b = int(b) # validate if either a or b is zero if a == 0 or b == 0: return 0 # check sign if a < 0 and b < 0: neg_sign_flag = False elif a < 0 or b < 0: neg_sign_flag = True else: neg_sign_flag = False # convert both integers to absolute value a , b = abs(a) , abs(b) # iterate addition accum = 0 for i in range(b): # make b the multiplier accum += a # return the multiplied value, with the appropriate sign if neg_sign_flag: return -accum else: return accum # User Input and Test Run a = input("please input the first integer: ") b = input("please input the second integer: ") print(str(a)+" multiplied by "+str(b)+" equals "+str(mult(a,b)))
Task 4 Question 12 Award 2 marks for input of 4 digit number and suitable label. Question 13 Award 2 marks for each scenario handled, for max of 10 marks. Question 14 Award 1 mark for each test A and B, 2 marks for Test C. Award 1 mark for correctly named and created jpg file. Question 15 Award 1 mark for changes made in the Random number generation section. Award 1 mark for player input and suitable label. Award 1 mark for game loop modifications.
TASK 2 MARKETFISH_2022_SAMPLE_CODE_ANSWER #Q7 msg_list = ['This fish is not heavy enough. Return to Extra Feed Pen.', 'This fish is not long enough. Return to Growing Pen.', 'This fish is not heavy enough and not long enough. Return to Original Pen.', 'This fish is heavy enough and long enough. Bag it for Market.'] number_fish = int(input('Please enter number of fish to weigh: ')) #Q6 minimum_weight = 1.2 minimum_length = 80 for i in range(number_fish): weight = float(input("Weight of fish (kg): ")) length = float(input("Length of fish (cm): ")) #Q7 if weight < minimum_weight and length > minimum_length: print(msg_list[0]) elif weight >= minimum_weight and length <= minimum_length: print(msg_list[1]) elif weight < minimum_weight and length <= minimum_length: print(msg_list[2]) else: print(msg_list[3])
TASK 2 AVERAGEFISH_2022_SAMPLE_CODE_ANSWER #Q7 msg_list = ['This fish is not heavy enough. Return to Extra Feed Pen.', 'This fish is not long enough. Return to Growing Pen.', 'This fish is not heavy enough and not long enough. Return to Original Pen.', 'This fish is heavy enough and long enough. Bag it for Market.'] number_fish = int(input('Please enter number of fish to weigh: ')) #Q6 minimum_weight = 1.2 minimum_length = 80 fishweight = [] #Q8 entry as [weight1, weight2, ...] fishlength = [] #Q8 entry as [length1, length2, ...] for i in range(number_fish): weight = float(input("Weight of fish (kg): ")) length = float(input("Length of fish (cm): ")) #Q7 if weight < minimum_weight and length > minimum_length: print(msg_list[0]) elif weight >= minimum_weight and length <= minimum_length: print(msg_list[1]) elif weight < minimum_weight and length <= minimum_length: print(msg_list[2]) else: print(msg_list[3]) #Q8 Store this data in fishweight, fishlength fishweight.append(weight) fishlength.append(length) # Q8 Calculate average weight and length of the Marketable fish if len(fishweight) > 0: average_weight = sum(fishweight) / len(fishweight) average_length = sum(fishlength) / len(fishlength) print('Average weight of Marketable Fish is '+str(round(average_weight, 1))) print('Average length of Marketable Fish is '+str(round(average_length, 1))) else: print('No Marketable Fish for this RUN')
TASK 4 4DGUESS_SOLUTION # Generate the four digit random number import random num = random.randrange(1000, 10000) # Initial Testing Only - Remove after program works print('The random number is now: '+str(num)) # Game Loop # Get user to input the 4 digit number n = int(input('Guess the 4 digit number: ')) # condition to test equality of the guess made. Terminate if true. if n == num: print('Great! You guessed the number in 1 try!') else: # ctr variable initialized - keep track of tries ctr = 0 # while loop repeats as long as the player fails to guess # correct number while n != num: ctr += 1 # number of attempts counter count = 0 # correct placed counter n = str(n) # type conversion to ease digit extraction num = str(num) # type conversion to ease digit extraction correct = ['X'] * 4 # list to store digits which are correct # for loop runs 4 times - 4 digit number for i in range(0, 4): # check for equality of digits if n[i] == num[i]: count += 1 correct[i] = n[i] else: continue # when not all digits are guessed correctly if (count < 4) and (count != 0): print('You only got '+str(count)+' digit(s) correct') print('') print('These numbers in your input were correct:') for k in correct: print(k, end=' ') print('\n') n = int(input('Enter your next choice of numbers: ')) # when none of the digits guessed correctly elif (count == 0): print('None of the numbers in your input match!')
print('') n = int(input('Enter your next choice of numbers: ')) # condition for equality if n == num: print('You guessed the number correctly!') print('It took you '+str(ctr)+' tries!')
TASK 4 5DGUESS_SOLUTION # Generate the FIVE digit random number import random num = random.randrange(10000, 100000) # EXTENSION # Initial Testing Only - Remove after program works print('The random number is now: '+str(num)) # Game Loop EXTENSION # Get user to input the 5 digit number n = int(input('Guess the 5 digit number: ')) # condition to test equality of the guess made. Terminate if true. if n == num: print('Great! You guessed the number in 1 try!') else: # ctr variable initialized - keep track of tries ctr = 0 # while loop repeats as long as the player fails to guess # correct number while n != num: ctr += 1 # number of attempts counter count = 0 # correct placed counter n = str(n) # type conversion to ease digit extraction
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 MSExam Papers · 2024
- BVSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices
- SST 2024 Prelim Paper 1 Ans [revised for 2025] Exam Papers · 2024
- SST 2024 Prelim Paper 1 [revised for 2025] Exam Papers · 2024
- [Notes for Computing] All Definitions/ TermsNotes/Practices · 2025
- [Notes for Computing] Heavily Compressed TextbookNotes/Practices · 2025
- All Computing Terms/DefinitionsNotes/Practices · 2025
- See all Computing notes

