Define a function that takes two integers x and k as parameters. The function should divide...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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] 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]
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.
-
Can a function that takes on only negative values have a positive derivative? If so, sketch an example.
-
Write a function that takes parameters r1 , r2 , n and generates random points (x1,x2) as follows - n random points that lie within a circle with center at (0,0) and radius r1 These points belong to...
-
. 4. Bank overdrafts repayable on * 1 point demand may be included in the cash and cash equivalent balance. True O False
-
The chamber of commerce of a Florida Gulf Coast community advertises that area residential property is available at a mean cost of $125,000 or less per lot. Suppose a sample of 32 properties provided...
-
Structures are sometimes subjected to very rapidly applied loads of extremely short duration. These types of loads are called blast or explosive loads. Consider how such a load time history may look....
-
Find the area to the right of 24.725 under the chi-square distribution with 11 degrees of freedom.
-
Queensland Electronics Company manufactures two large-screen television models, the Novelle, which has been produced for 10 years and sells for $910, and the Zodiac, a new model introduced in early...
-
The following information about the work-in-process inventory pertains to the Remington Plant for the month of July (all materials are added at the beginning of the process): Materials Conversion...
-
Submersibles with clear plastic hulls have the potential to revolutionize underwater leisure. One small submersible vehicle has a depth-control system as illustrated in Figure E4.9. (a) Determine the...
-
Faith Busby and Jeremy Beatty started the B&B partnership on January 1, Year 1. The business acquired $87,500 cash from Busby and $162,500 from Beatty. During Year 1, the partnership earned $60,800...
-
Q3 (a) (b) A new lunar lander is being designed for future missions to the moon, illustrated schematically in Figure Q3a. The lander has four legs, each of which contains a linear spring of stiffness...
-
Megamart provides the following information on its two investment centers. Investment Center Electronics Sporting goods Sales $ 35,000,000 17,280,000 Income $ 2,975,000 2,160,000 Average Assets $...
-
1. What is Tim wise discussion about dominant and subordinate groups with regards to underprivileged and privileged groups in society? 2. What does Tim wise mean when he says "feeding denial" as it...
-
A set of data items is normally distributed with a mean of 60 and a standard deviation of 8. Convert each data item to a z-score. 24) 68 26) 74 25) 92 27) 100 28) 48 29) 30 30) 40 31) 52 32) 78 33)...
-
What are the health and safety responsibilities of employees? We should take care of our own safety and health. Do not interfere or misuse what has been provided for your health, safety or well...
-
KW acquired 60% of RB's equity shares on 1 July 20X5. KW elected to measure non-controlling interests in RB at their fair value of $570,000 at acquisition. KW had retained earnings of $290,000 at...
-
What kind of rays are X-rays?
-
Determine the one-sided limits of the function f (x) in Figure 14, at the points c = 1, 3, 5, 6. -1 -2 -3 -4 FIGURE 14 Graph of f(x)
-
Use the result of Exercise 32 to compute the areas of the polygons in Figure 27. Check your result for the area of the triangle in (A) using geometry? 3, 5 (2, 3) (5, 3) (3, 2) -3-2-1 12 3 4 5 FIGURE...
-
What do the following quantities represent in terms of the graph of f (x) = sin x? a. Sin 1.3 sin 0.9 b. c. F'(0.9) sin 1.3- sin 0.9 0.4
-
Describe the process of valuing the entrepreneurs ownership interest in a two-stage investment. Refer to Tables 13.10 and 13.13. Data from table 13.10 Data from table 13.13 Market potential...
-
Euro Exchange Rates. The exchange rate that we consider is the amount of euros that one can purchase for one U.S. dollar. We have \(T=699\) daily observations from the period April 1, 2005, through...
-
Evaluate the current yield curve level and structure using the following screens: a. YCRV or GC to access yield curves. b. FWCV to determine implied forward rates. c. USoo03M, USoo06M, USoo09M, and...
Study smarter with the SolutionInn App