Professional Documents
Culture Documents
SECTION A
MULTIPLE CHOICE QUESTIONS
1. What will the following algorithm display? C. 84
a ← 13 D. 126
b ← 17
a←a+1 4. The output of the following algorithm is
c←a/7 a ← “Milk”
DISPLAY(c) a ← a + “Cookies Soda”
DISPLAY(a) a ← a + “Chips”
DISPLAY(b) a ← a + “put them in a bag so you know they
stay crisp”
A. 2 14 17 DISPLAY(b)
B. 13 17 5
C. 2 12 2 A. Milk
D. 14 17 2 B. Milk Cookies Soda
C. Put them in a bag and they stay crisp
2. What will the following algorithm display? D. Milk Cookies Soda Chips put them in a bag
a ← 13
a ← 17 5. Which of the following is the output of the
c←a+1 following algorithm?
DISPLAY(a) a ← 26 MOD 2
A. 13 DISPLAY(a)
B. 17
C. 18 A. 26
B. 13
D. 19
C. 0
3. What is the output of the following algorithm? D. 1
a ← 11
a ← a + 35 6. What will the following code segment display?
b ← a MOD 2 a ← 13
b←a×b b←5
DISPLAY(b) temp ← a
a←b
A. 0 b ← temp
B. 42 DISPLAY(a)
DISPLAY(b)
A. 13 5
B. 5 13
C. a b
D. 13 13
11. Three numbers need to be put into order from Which line of the code can be replaced inside
smallest to greatest. Which of the following the braces {} to fix the following loop so it will
algorithms can be used to accomplish this? not be an infinite loop?
A. If the first number is greater than the middle
one, swap them. Then, if the middle number A. name ← INPUT ()
is greater than the last one, swap them. B. If name <> “done”
Then, if the first number is greater than the C. count = count + 1
last, swap them. D. name ← studentRoster
B. If the first number is greater than the middle
one, swap them. Then, if the middle number 15. The figure below shows a circuit composed of
is greater than the last, swap them. two logic gates. The output of the circuit is
C. If the first number is greater than the last, true
swap them. Then, if the first number is
greater than the middle number, swap them.
D. If the first number is greater than the middle,
swap them. Then, if the middle number is
greater than the last, swap them. Then, if the
first number is greater than the middle, swap
them.
SECTION B
LAB SESSION
QUESTION 1:
Alison created a list of her favourite fruits in order of preference. The name of the list is favFruits and it
contained the following elements:
favFruits = [“plum”, “strawberry”, “apricot”, “watermelon”, “orange”,
“apple”, “mango”]
She later found out that she had mistakenly swapped the positions of her most preferred fruit “mango” and her
least preferred fruit “plum”.
QUESTION 2:
Precious is designing a blog for her project. On the blog site, she wants to implement a restricted area where
only girls in grade 11 can access. To access this page, the user needs to answer the following questions?
1) What is your name?
2) What is your gender?
3) What grade are you in?
a) Write an algorithm that will display: You are welcome, Janet! Click here to access
the requested page if Janet meets all the required criteria to access the page OR Sorry
Faith, only grade 11 girls can access the requested page for Fait who is a
girl but not in grade 11 OR Sorry Michael, the requested page is only for
girls.
b) Implement the algorithm using Python Good Luck!