Study notes
No notes have been generated for this topic yet. Open the topic page online and click Generate notes first.
Past exam questions (12)
2020 · Part A · Q11 · p.9
The intention of the JavaScript function below is to return a student grade descriptor based on a percentage grade as shown in the table to the right. [Table: Two columns, 'Percentage Grade' and 'Descriptor'. Rows: '80 or over' (Distinction), 'From 40 to 79' (Pass), 'Less than 40' (Unsuccessful).] [JavaScript code snippet for a function getGradeDescription(percentageGrade).] The code runs without any syntax errors but it does not always return the correct grade descriptor. Outline one way in which the function could be modified so that it works as intended.
2020 · Part A · Q13(a)(ii) · p.11
What is the data type of the variable called found? [Visual aid: Python code for a linear search algorithm]
2020 · Part C · Q16(b)(v) · p.10
Modify the program so that it calls the function is_strong for each password in the list test_passwords and displays all the strong passwords. When the program is run the output may look as follows: [Table: Score and Password. Header row: 'Score', 'Password'. Separator line. Data rows: '1', 'sun'; '6', 'Sun'; '11', 'Sunshine'; '0', '12345'; '11', 'Moonlight'.] The weakest password is: 12345 Score: 0 The strong passwords are: Sunshine Moonlight
2020 · Part C · Q16(b)(iv) · p.10
Write a function definition called is_strong which accepts a password as a parameter and returns True if the password is strong; False otherwise. A password is deemed strong if it contains more than seven characters and both lowercase and uppercase letters. The first line of the function definition will look like this: def is_strong(password):
2020 · Part C · Q16(b)(iii) · p.9
Amend the program so that it determines and displays the weakest password in the list along with its score. When the program is run the output may look as follows: [Table: Score and Password. Header row: 'Score', 'Password'. Separator line. Data rows: '1', 'sun'; '6', 'Sun'; '11', 'Sunshine'; '0', '12345'; '11', 'Moonlight'.] The weakest password is: 12345 Score: 0
2020 · Part C · Q16(b)(ii) · p.9
Insert a line of code to change the password contained at index 4 of the list test_passwords from 123456789 to Moonlight. When the program is run the output may look as follows: [Table: Score and Password. Header row: 'Score', 'Password'. Separator line. Data rows: '1', 'sun'; '6', 'Sun'; '11', 'Sunshine'; '0', '12345'; '11', 'Moonlight'.]
2020 · Part C · Q16(b)(i) · p.9
Make the following changes to the program: (i) Amend the program so that the output is displayed in the following format: [Table: Score and Password. Header row: 'Score', 'Password'. Separator line. Data rows: '1', 'sun'; '6', 'Sun'; '11', 'Sunshine'; '0', '12345'; '5', '123456789'.]
2020 · Part C · Q16(b) · 80 marks · p.7
(b) Open the program called Question16_B.py from your device. The source code is shown on the next page and described briefly below. Before making any changes, you should use the format CandidateNumberQuestion16_B.py to save your file. For example, if your candidate number was 123456 you would save the file as 123456Question16_B.py. Enter your Examination Number in the space provided on line 2. This program is very similar to that provided for part (a) with two main differences: - The code to calculate the password score is contained in a function definition called calculate_score. This function accepts a parameter called password and returns the calculated score. - Instead of prompting the user to enter a single password this program, uses a list of hard-coded passwords called test_passwords. When the program is run it loops through each password in the list test_passwords. As it does so, it calculates and displays the score of each password. A sample run of the program is shown below: 1 6 11 0 5 [Visual aid: Sample program output showing scores for a list of passwords]
2020 · Part C · Q16(a)(viii) · p.6
Change rule 1 so that the score is adjusted according to the password lengths as shown in the following table. [Table: Password Length and Score. Rows: 'Greater than 7 characters' with '+5 points', 'From 4 to 7 characters' with '+2 points', 'Less than 4 characters' with '-2 points'.] The table below shows the scores that would be awarded for a variety of passwords. You could use this information to test your program. [Table: Password and Score. Rows: 'sun' with '-1', 'Sun' with '6', 'sun2' with '9', '2sun3' with '12', '3Sunshine' with '19', '3Sunshine7' with '22'.]
2020 · Part C · Q16(a)(vii) · p.6
Implement a new rule (rule 7) so that the score is reduced by 10 points if the password contains only digits. When the program is run the output may look as follows: Enter a password: 1234 Password: 1234 Score: -1 [Visual aid: Sample program output showing input and modified output]
2020 · Part C · Q16(a)(vi) · p.6
Implement a new rule (rule 6) so that the score is increased by: - 1 point if the first character of the password is a digit - 1 point if the last character of the password is a digit - 2 extra points if both the first and the last characters of the password are digits When the program is run the output may look as follows: Enter a password: 3Sunshine7 Password: 3Sunshine7 Score: 22 [Visual aid: Sample program output showing input and modified output]
2020 · Part C · Q16(a)(v) · p.5
Implement a new rule (rule 5) so that the score is increased by 5 points if the password contains at least one digit (any integer in the range 0 to 9: +5 points). When the program is run the output may look as follows: Enter a password: 3Sunshine Password: Score: 18 3Sunshine [Visual aid: Sample program output showing input and modified output]