Semester 1 2023 Assignment One Transformation
In this assignment, you will create a Python program to transform a full name into a number using a specific method. This will involve using various programming skills such as selection, loops, and user-defined functions. The aim is to improve your problem-solving abilities, system design, and basic programming skills.
- A. Generate an integer n1 from the ‘firstname’ as input.
Starting from the leftmost character of ‘firstname’, convert each letter to its ASCII value and calculate the sum of all these values to obtain n1.
- B. Generate an integer n2 from the ‘surname’ as input.
Repeat the process in (A) for ‘surname’ to obtain an integer n2.
- C. Calculate and display n3, which is the squared digit length of n1.
The squared digit length of an integer can be obtained by adding up the squares of its digits and repeating the process until the result is either 1 or 4. The number of times this process is repeated to reach 1 or 4 is the squared digit length. For example, starting with the integer 85, we get:
8^2 + 5^2 = 89
8^2 + 9^2 = 145
1^2 + 4^2 + 5^2 = 42
4^2 + 2^2 = 20
2^2 + 0^2 = 4
This process shows that the squared digit length of 85 is 5.
It is worth noting that this process will always eventually reach either 1 or 4. The squared digit length of 1 and 4 is zero, as we do not actually need to apply the process to reach the stopping condition. Interestingly, though, if we did apply the process to 1, we would keep getting 1, but if we applied it to 4, we would get a repeating sequence: 4, 16, 37, 58, 89, 145, 42, 20, 4.
D. Calculate and display n4, which is the squared digit length of n2.
Repeat the process in (C) for n2 to obtain n4.
E. Calculate and display n5, which is the greatest common divisor of n3 and n4.
Here are some examples. To make it clear, input characters are presented in BOLD fonts and blue color.
Example 1
Enter your first name and surname: James Bond The integer n1 from first name James is 496. The integer n2 from surname Bond is 387.
The squared digit length of n1 is 6. The squared digit length of n2 is 12.
Example 2
Enter your first name and surname: james bond The integer n1 from first name james is 528. The integer n2 from surname bond is 419.
The squared digit length of n1 is 12. The squared digit length of n2 is 5. The GCD of n3 and n4 is 1.
Example 3
Enter your first name and surname: Harry Potter
The integer n1 from first name Harry is 518. The integer n2 from surname Potter is 638.
The squared digit length of n1 is 11. The squared digit length of n2 is 5. The GCD of n3 and n4 is 1.
Submission
In the template file ‘transformation_template.py’ provided on iLearn, a set of user-defined functions has already been declared. Your task is to provide the implementation code for each of these functions and call them in your program’s main function or another function. You can define additional user-defined functions to simplify your code and make your solution clear.
Student declaration of academic honesty
Each file has a declaration:
# Student Declaration
# I [insert name and Student ID here] declare that this is my own work and that # I have not used any code or logic from other people or from sources outside of the unit.
#
# I understand that it is ok to look at COMP6010 videos and COMP6010 resources # and that researching how certain python operators / functions work is ok.
#
# [] <== put an x in here to indicate you have read and agree to the above statements.
As it says, please put an ‘x‘ inside the square brackets so it updates to:
# [x] <== put an x in here to indicate you have read and agree to the above statements.
Submit: To submit your completed assignment, you should upload a Python file named ‘yourSID_transformation.py’ to iLearn.
Note: Submit your program early, and you may resubmit until the deadline. Late submissions will receive penalty.
In this assignment, your program will be hand-marked (70%) and tested on various sets of data. Additionally, the appropriate implementation and use of the pre-declared user-defined functions in the provided template will be checked (30%).
Note: If your solution does not implement and call the provided user-defined functions properly, you will receive a mark of 0 in handmarking.
Consult with your tutor or Yan Wang if you have any questions about this assignment. Extensions will only be granted for serious and unavoidable disruptions. Contact Yan Wang as soon as possible if you experience a disruption that affects your ability to submit this assignment.
Get expert help for Fundamental Computer Science and many more. 24X7 help, plag free solution. Order online now!