# Ball pit

Calculate the number of balls needed to fill a ball pit.

## Try

Select the button below to open the Python program in a new window. Run the program and read the lines of code to see if you can understand how it works. It will be helpful to arrange your display so that you can have this browser window on one side of the screen and the code on the other.

Watch this video to learn about the new concepts shown in the program:

#### Knowledge Organiser

Just like in maths you can use brackets to change the default order of operations. Known as BIDMAS or BODMAS: Brackets, Indices, Division, Multiplication, Addition, Subtraction.

You can also structure your program into more than one subprogram.

## Investigate

Explain why both `int` and `float` are used in programming. Why don't we always use float for storing numbers?

Floats and integers are stored in different ways by the computer. Floats usually use more memory than integers. Good programmers write programs that only use the memory they need.

Why have comments been added to the end of lines 21 for the units instead of storing ball_pit_radius as "1m" and the ball_pit_height as "0.2m" as you might in Maths or Science?

Comments allow the programmer to remember the units of measurement. The processor can't perform arithmetic on strings, only integer and float data types. Including the unit with the number would mean it is a string because letters are strings.

## Make

### Success Criteria

Change the program below so that it:

1. Asks the user to enter the radius and height of the ball pit.
2. Asks the user to enter the radius of one ball in meters.
3. Casts the number of balls to be an integer + 1.

#### Typical inputs and outputs from the program would be:

Enter the radius of the ball pit in meters: 2

Enter the height of the ball pit in meters: 0.5

Enter the radius of one ball in meters: 0.05

You need 9000 balls to fill the ball pit.

#### Help

Use the flowcharts if you need more support in understanding the steps required to meet the criteria. Use the Parsons code sorting exercise only if you are really stuck.

## Evaluate

Run your code to check that your program has met the success criteria and produces the required output.

# You need 4500 balls to fill the ball pit.

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500