• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

TM111 TMA02. EXAM-with 100% verified solutions-

Document preview thumbnail
Preview 2 out of 7 pages

TM111 TMA02. EXAM-with 100% verified solutions-

Content preview

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).

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

Seller avatar
STUVIAEXCEL
4.0
(1)
Sold
5
Followers
3
Items
973
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions