Question
Please read the instructions and the problem statement. Ensure that the names for file/variables/functions are related to the problem statement and not vague. Include a
Please read the instructions and the problem statement.
Ensure that the names for file/variables/functions are related to the problem statement and not vague.
Include a docstring for each function. The docstrings must be placed below the function header. Use multiline comment style """description""" (See classroom examples)
Add comments if you think that a section of your script needs any explanation. Do not over comment as it becomes unreadable.
Test your scripts for acceptable values as specified in each question before submitting.
If you are resubmitting your assignment, please resubmit all the files needed for this assignment
Include a function called input_large_number. The input must be numbers 0 - 9 and must be appended to a list called digits
For example a number such as 123456789 is represented via a list as [1,2,3,4,5,6,7,8,9], where 9 is the least significant digit
Ensure that the function uses the try except clause and a loop to input multiple numbers to form the list.
During input, ensure that the most significant digit is not 0 (in other words the number does not have any leading zeros)
The digits are ordered from most significant to least significant in left-to-right order and each digits[i] is the ith digit of the integer
Return the list to main
Create another function called adding_one, that uses the list as the input parameter.
This function should contain the logic to add one to the least significant digit and the list contain the resulting number as represented by the list
The function should return the changed list
Note: The list should NOT be converted to a number to do the arithmetic. The processing must use the list as is
Create a function called main that calls the functions in the following order:
input_large_number. The function returns a list
Pass this list to the adding_one function that returns the changed list
Display the returned list
Note: each item in the list is a single digit.
For example:
input digits = [1, 2, 4, 5]
Adding one to the least significant item:
output: [1, 2, 4, 6]
input digits = [9, 9, 9]
Adding one to the least significant item:
output: [1, 0, 0, 0]
input digits = [8, 9]
Adding one to the least significant item:
output: [9, 0]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started