SCRATCH question
This question focuses on Part 3 (selection) and Part 4(repetition). As inspiration for this question, you might like torevisit Activity 4.8 of Part 4, which uses a list of specificcharacters.
The teacher wishes to see if her pupils can make sense of wordsin which certain letters have been replaced by question marks.
She requires a when[space]key_pressed script that will take aword from the user and display a new word that is the same as theoriginal except that each letter in the middle of the alphabet (jto q inclusive) has been replaced by a question mark (?).
The user should input the word as a single string and the newword that is displayed should be a single string.
For example, if the user enters
‘elephant’
then
‘e?e?ha?t’
is displayed.
One way to think about creating the new word for display is tostart with the new word as an empty string and then work throughthe letters in the original word from first to last, creating thenew word incrementally by adding either the letter concerned or aquestion mark as appropriate. This might be visualised as in Figure2.
Figure 2
Long description
Recall that, as in Part 4 Activity 4.8, a simple way to checkwhether a given character is one of a set of specific characters isto check whether it is in a list that has been populated with thosespecific characters.
a.Create and write down an algorithm to solve this problem. Youmight like to use the ideas above, or alternatives of your own.
(10 marks)
b.Create a when[space]key_pressed script to implement youralgorithm. Depending on your algorithm and the way in which youchoose to implement it, you may also decide to have awhen_green_flag_clicked script.
Take a screenshot of your script(s) and paste it into yourTMA document.
(11 marks)
c.Copy the following table into your TMA document and add to ittwo tests you would perform to check whether the completed programfulfils the specification. (Several tests might be appropriate;however, you are only required to add two.)
(4 marks)
Save your OUBuild project for Question 3 and submit it asTM111_02_Q3_PI.sb2 (where PI is your OU personal identifier, e.g.A1234567) in your TMA zip file. Alternatively, you may use yourOUCU instead of your PI.
Using SCRATCH
SCRATCH question This question focuses on Part 3 (selection) and Part 4 (repetition). As inspiration for this question,
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am