1. Describe what is meant by a variable. Please consider the key words we are looking for. Hint: M_____ location and a value that c_________. (2 marks)
2. List the variabes in this program.
3. In the above code, explain why the output of the program will be "Over 13" even though the age of John Smith is 11.
4. State the most appropriate data type used to store employee_name, points and letter sent.
5.
The data shown above is stored in a database table called Tasks. Write an SQL statement to select the EmployeeName field for all records that have negative Points.
6. State the wildcard that can be used in SQL to show all fields from a table.
7. The array is zero based, so _________________holds the value "Kristen".
8. In reference to the array and context above (of employees) what is the following code doing?
9. If the values in the for loop below were changed to range(2,4), the code would print:2,3. What is the current output with (1,4)?
for k in range(1,4):
print(k)
0,1,2,3
1,4
1,2,3
1,2,3,4
10. What is the output of the following code? (note it is a single for loop)
for p in range(1,6):
print(p)
2,4,6
1,6
1,2,3,4,5
2,3,4,5
11. The following loop is called a: __________. Note that one loop is inside the other. The second loop runs five times (12,3,4,5,). (1 mark)
for k in range(1,4):
for p in range(1,6):
print(k+p)
12. Analyse the following code. What are the first three numbers that are output? (Grade 8/9 question)
for k in range(1,4):
for p in range(1,3):
print(k+p)
1,3,6
2,4,6
2,3,3
2,3,4
13. For the code above, state how many times line 3 will be executed if the algorithm runs through once.
14. List the programming constructs (name three for 3 marks) you can spot in this code. (3 marks)
def main():
score=0
while score>0:
print("Well done")
if score==100:
print("Especially well done")
15. Name the two logic gates shown in this diagram. (write your answers separated by commas) (2 marks)
16. Refer to the image and truth table above. Which arrow (A, B, C or D) is indicating that the value filled in for the output Q is INCORRECT?
17. What is the expression that relates to the logic gate diagram below? Note that "¬" is a NOT gate and a "V" is an OR gate.
18. Read the context below and fill in the blanks.
19. Consider the following pseudocode.Along with 'title' what is the other parameter that needs to be taken in on line 01, for the program to run.
20. What does line 03, in the above code, do?
21. In the same context as above (book code generation), fill in the blanks for line 02 in this pseudocode.
22. Note that a function always returns a single value (while a procedure does not). What is likely to go in the blank on line 04?
23. State four benefits to a programmer of using sub programs.
24. The following example shows the first two passes of a bubble sort (one more pass is needed to complete the sort). Fill in the blanks for the third line in the second pass.
Bubble sort example
====================
This algorithm could be used to sort the following list:
3, 2, 4, 1, 5
First pass
===========
The first loop of the algorithm would produce:
3, 2, 4, 1, 5 (2<3 so the two values are swapped)
2, 3, 4, 1, 5 (3<4 so the two values are not swapped)
2, 3, 4, 1, 5 (1<4 so the two values are swapped)
2, 3, 1, 4, 5 (4<5 so the two values are not swapped)
2, 3, 1, 4, 5 (First pass completed)
Values were swapped so the algorithm needs to run again.
The second loop of the algorithm would start with the final
list and run again as follows:
Second pass
============
2, 3, 1, 4, 5 (2<3 so the values are not swapped)
2, 3, 1, 4, 5 (1<3 so the values are swapped)
____________?(3<4 so the values are not swapped)
2, 1, 3, 4, 5 (4<5 so the values are not swapped)
2, 1, 3, 4, 5 (Second pass completed)
1,3,2,4,5
1, 3, 2, 4, 5
2, 3, 1, 4, 5
2, 1, 3, 4, 5
25. Refer to the following set of steps demonstrating a merge sort. Fill in the blanks for points 2 and 3 in the algorithm for Merge sort.
26. Convert the denary number 132 into an 8 bit binary number.
27. Convert the binary number 11000101 to its hexadecimal equivalent.
28. Convert the binary number 00001111 to its hexadecimal equivalent.
29. The following is an example of a ______________(not a while loop) that prints out the numbers _____________ in ascending order.
30. State four tools or facilities that an IDE commonly provides. (4 marks)