Question: Some whole numbers can be split into smaller pieces, where each piece contains the same number of digits. For a subset of the whole numbers
Some whole numbers can be split into smaller pieces, where each piece contains the same number of digits. For a subset of the whole numbers which can be split evenly, the pieces are in numerically increasing order. Examples:
154152 can be split evenly into two-digit pieces (15, 41, 52) increasing order
154152 can be split evenly into three-digit pieces (154, 152) not increasing order
154152 cannot be split evenly into five-digit pieces
173 can be split evenly into one-digit pieces (1, 7, 3) not increasing order
173 can be split evenly into three-digit pieces (173) increasing order
173 cannot be split evenly into two-digit pieces
Design, implement and test a Python program which checks to see if a user-supplied whole number can be split evenly into 2-digit pieces and 3-digit pieces which are in numerically increasing order.
1. The program will prompt the user to enter a whole number. If the user enters an invalid input (anything other than a whole number), the program will repeatedly prompt the user until a valid input is entered.(Use https://docs.python.org/2/library/functions.html?highlight=type#type function )
2. The program will count the number of digits in whole number. Check if the number can be split in 2-digit pieces and 3-digit pieces. Send an appropriate message to the user and repeatedly prompt user to enter a valid input.
3. The program will split the number into 2-digit pieces and display those pieces on one line (separated by commas).
4. The program will report whether or not the pieces are in numerically increasing order. If there is only one piece, it is defined to be in numerically increasing order.
5. The program will split the number into 3-digit pieces and display those pieces on one line (separated by semicolon).
6. The program will report whether or not the pieces are in numerically increasing order. If there is only one piece, it is defined to be in numerically increasing order.
Assignment Notes
1. You may not use any collection (such as a list, tuple, or dictionary) in your program.
2. Be sure to prompt the user for the two inputs in the correct order. Also, your program cannot prompt the user for any other inputs. To grade your program, your TA will enter a series of inputs.
3. You may not convert the wholenumber to a string to calculate the number of digits.
Enter whole number315532
3-digit pieces
315;532 Increasing order
2- digit pieces
31,55,32 Not increasing order
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
