Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python program called large_integer Include a function called input_large_number. The input must be numbers 0 - 9 and must be appended to a list called

Python program called large_integer

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

3.49 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Heres a Python program called lar... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions