TM111 TMA02. EXAM -with 100% verified solutions -2023 -2024 Question 1 A. Complete the following step-by-step description of what the when[space]key_pressed script does when the user starts the program with the green flag, then presses their space key, and enters 'Sami' , and then 34. Your description should make clear what data is stored in the variables and the list involved, and the result of any comparison that is made . The user is asked to enter a pupil's name. Their input, 'Sami', is stored in the variable name. The user is asked to enter the number of lengths the pupil can swim…. Algorithm Explanation: • Green Flag is Clicked – This will delete any existing pupil’s name in the “dolphin_badge_list ” variable • When Space Key is Pressed - This will perform the following steps o Wait to enter Pupil’s Name – Enter “Sami” ▪ Sami will be stored in the variable “name ” o Wait to enter the number of lengths the pupil can swim – Enter “34” ▪ 34 will be stored in the variable “number_of_lengths ” o Percentage Length is computed multiplying the value of “number_of_lengths ” to 2.5 ▪ The result will be stored in the variable “lengths_percentage ” o Say – The program will output the concatenation of the value of “lengths_percentage ” and “%” for 2 seconds o If condition - If the computed “lengths_percentage ” value is greater than 75 then ▪ "Sami” will be inserted to the “dolphin_badge_list ” variable B. I. Identify a numerical value in this program that might appropriately be stored in a constant. (There may be more than one possibility but you are only required to identify one. You are not asked to implement this constant. Ans: The number 75 in the if condition II. What might be an appropriate name for the constant you have chosen? Ans: The possible constant name is “ threshold_percentage ” which indicates a below lower limit percentage value. C. Amend the when_green_flag_clicked and when[space]key_pressed scripts so that: • if a pupil can swim more than 75% of the maximum number of lengths their name is added to the list dolphin_badge_list • otherwise their name is added to a list duckling_badge_list (which you should create and initialise appropriately).
Preview 2 out of 7 pages
Exam (elaborations)
TM111 TMA02. EXAM-with 100% verified solutions-
Preview 2 out of 7 pages
TM111 TMA02. EXAM-with 100% verified solutions-
Content preview
Document information
- Uploaded on
- September 12, 2023
- Number of pages
- 7
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
$10.49
Wrong document? Swap it for free
Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF