Question: Define a function that takes two integers x and k as parameters. The function should divide x into k (mostly) equal integers and combine

Define a function that takes two integers x and k as parameters. The function should divide x into k (mostly) equal integers and combine each of these integers into a list. The function should return this list. The value of k has to be a positive integer;, if it isn't, an error message should be displayed. To test your function, read two integers from the user, call the function by passing these two integers as arguments and print the list returned from the function. Warning: You are not allowed to use any built-in functions: you are supposed to compute the result using iterations. SAMPLE OUTPUT 1 (bold parts are entered by user): Please enter the number to be partitioned: 45 Please enter the number of partitions: 10 The partitioning is as follows: [5, 5, 5, 5, 5, 4, 4, 4, 4, 4] SAMPLE OUTPUT 2 (bold parts are entered by user): Please enter the number to be partitioned: 32 Please enter the number of partitions: 4 The partitioning is as follows: [8, 8, 8, 8] SAMPLE OUTPUT 3 (bold parts are entered by user): Please enter the number to be partitioned: -33 Please enter the number of partitions: 8 The partitioning is as follows: (-5, -4, -4, -4, -4]
Step by Step Solution
3.29 Rating (146 Votes )
There are 3 Steps involved in it
httpscl1pnetgood us... View full answer
Get step-by-step solutions from verified subject matter experts
