A program is being developed to generate a unique laboratory Asset Tracking Key (ATK).
The letter part of the registration key is made up of the first letter of the building name joined with the first three letters of the equipment's category. All letters must be in uppercase.
The number part of the registration key is the sum of the ASCII values for each digit in the 5-digit equipment asset number.
The registration key for equipment in building Lab Alpha with category Centrifuge and asset number 72019 is LCEN259, all in uppercase.
# Global variables
building = ""
category = ""
asset_num = ""
def generate_atk(building, category, asset_num):
letter_part = building[0] + category[0:3]
total = 0
for char in asset_num:
total = total + int(char)
return letter_part + str(total)
# Main program
building = input("Enter building name: ")
category = input("Enter equipment category: ")
asset_num = input("Enter 5-digit asset number: ")
atk_code = generate_atk(building, category, asset_num)
print("Asset Tracking Key:", atk_code)
Amend the code to:
generate_atk function to distinguish them from the global variables with the same names.system_header, with no parameters, to display a message welcoming the user to the asset tracking system.system_header procedure before asking for any user input.generate_atk() function only if the asset number is valid.int() function in the number part calculation rather than using a function that returns the ASCII value of the character.Do not add any additional functionality.
Practise Edexcel GCSE Computer Science Develop code with exam-style questions for GCSE Computer Science. 57 questions covering Decomposition and abstraction to solve problems, Read, write, analyse and refine programs, Converting algorithms into programs, Techniques for readable, maintainable code, Identifying and correcting program errors, and Evaluating program fitness and efficiency, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.