Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use python to solve this problem Problem 2 - balls.py: Pool ball arrangements [5 points] Write a function ball_rows ) which takes a non-negative integer
use python to solve this problem
Problem 2 - balls.py: Pool ball arrangements [5 points] Write a function ball_rows ) which takes a non-negative integer argument n and returns the number of rows necessary for n pool balls in a standard arrangement The standard arrangement has 1 ball on the first row, two on the second, three on the third, and so on row row-balls balls-so-far 45 6 78 9 10 11 12 13 14 15 10 15 21 4 4 16 17 18 19 20121) 6 For example, the figure above illustrates the case of n = 18, which corresponds to a return value of 6 Hint This is exactly the calculation of 1+2+3+ + m, which was our first ever loop. Only the termination condition is different, which now is with respect to the sum. Although there are other ways to go about the details of the implementation, if you're stuck, you might want to start by re-implementing our first loop using while and then modifying that (textually, it's a very small modification)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