Lesson video

In progress...

Loading...

Hello, my name is Mrs. Holborow, and welcome to computing.

I'm so pleased you've decided to join me for the lesson today.

This is a project-based lesson, where you'll create a programme using a design and then test the programme to ensure it meets the requirements.

Welcome to today's lesson from the unit "programming sequence".

This lesson is called "Programming Project: Sequence two", and by the end of today's lesson, you'll be able to implement a programme from a design and test the programme.

Shall we make a start? We will be exploring these keywords in today's lesson.

Implementing.

Implementing.

Writing and developing code to create a working programme based on a design or plan.

Testing.

Testing.

Running a programme with different inputs to check for errors and ensure it works as expected.

Look out for these keywords in today's lesson.

Today's lesson is broken down into two parts.

We'll start by implementing a programme, and then we'll move on to test a programme.

Let's make a start with implementing a programme.

Implementing a programme is about taking a plan, for example, a flow chart, and creating the programme.

So you can see here, I have a flow chart for the SplashZone Water Park.

So I have an output which says, "Welcome to SplashZone Water Park", and then I ask the user, "What is your name?" If I convert this into a programme, the output would look similar to this.

So we have the welcome message, "Welcome to SplashZone Water Park", and then we have the question to the user, which says, "What is your name?" When implementing a programme, it's best to solve one part at a time, in a step-by-step sequence.

Carefully consider the order of these parts and which parts don't depend on others.

So here's a plan for the SplashZone Water Park ticket booking system.

We've broken down the problem into smaller sections.

So we have display ticket prices.

The system will need to display the ticket price to the user.

We have the entrance price, where we're going to calculate the entrance price, which will be the number of people multiplied by the ticket cost, multiplied by the number of days, and then we'll need to display that total ticket price.

We then have the car parking price, so we're going to have to calculate the parking price, which is calculated by multiplying the number of cars by the parking price.

And then we'll have to display that total car parking price and the new total.

We then have the collect payment, so we'll ask for payment from the user by displaying the ticket cost, and then we'll calculate the change amount, so the payment amount minus the total amount.

And then lastly, we have the ticket summary.

So showing the payment and change amount, if there is any.

Sam says, "I'm going to start with the display ticket prices as this is the first thing the programme needs to do." That sounds like a sensible idea to me, Sam.

Time to check your understanding.

Creating a plan comes before implementation.

Is this true or false? Maybe pause the video whilst you have a think.

That's right.

It's true.

It's important to fully understand the different parts of a project and to plan the programme before you start implementing.

Otherwise, you can easily make mistakes.

When implementing a programme from a flow chart, remember the flow chart symbols can guide you.

So the terminal symbol represents the start or end of a programme.

The process symbol represents any action, such as calculations or any step where data is manipulated.

An example might be total is equal to price multiplied by quantity.

The input output symbol is represented by a parallelogram.

This represents any action that involves user input or programme output.

Time to check your understanding.

What does this symbol represent in a flow chart? Is it A, a terminal? B, input or output? Or C, a process? Pause the video whilst you have a think.

Did you select process? Well done.

We're now moving on to our first activity of today's lesson, and you're doing a fantastic job, so well done.

Implement your ticket sales system for SplashZone Water Park using your ticket booking system plan.

If you don't have a plan, you can use the plan provided in the additional materials for this lesson.

Pause the video whilst you go and have a go at implementing the solution.

Check your program's output against the example output to ensure it shows all of the necessary information correctly.

So here we have the output, which says, "Welcome to SplashZone.

We're excited to have you here.

Entrance ticket price is 25 pounds per person per day.

What is your name?" The user responds with "Sam".

"How many days will you be visiting SplashZone?" The user responds with "two".

"How many tickets do you require?" The user responds with "three".

"How many cars will you need parking for? At 10 pounds per car." The user responds "one".

And then we have a message which says, "Thank you, Sam." So the user's name.

"Your total cost for three people for two days at SplashZone is 160 pounds.

Please enter your payment amount." The user enters 200, and then we say, "Thank you for your payment of 200 pounds.

Your change is 40 pounds." So your programme should have an output that looks similar to this.

Pause the video whilst you go and check your programme.

Okay, we're now moving on to the second part of today's lesson, where we're going to test a programme.

Jun has a question.

Jun says, "Why do we test programmes?" Maybe pause the video whilst you have a think about the answer.

Testing helps to find and fix errors before users experience problems. It ensures the programme works as expected with different inputs.

Testing helps to improve reliability and user experience.

It would be bad if the Splash park ticket booking system was sent out to users and they started to try and book tickets and it didn't work properly.

You may have checked your code was working as you implemented different parts or lines.

This is called iterative testing.

Iterative testing is where you test that your programme works throughout its creation.

By running your code and testing it often, errors are much easier to detect and correct.

Time to check your understanding.

Iterative testing happens as the programme is being implemented.

Is this true or false? Pause the video whilst you have a think.

Did you select "true"? Well done.

Iterative testing is where you test that your programme works throughout its creation, so you don't wait till the end and just do the testing when it's finished.

This is a typical error that you may have come across.

So here we have the message that says, "Thank you for your payment of 120.

0.

Your change is 10.

0." It doesn't quite look right, because in currency, we would have two zeros at the end, because we need to represent all of the pence that are available in a pound.

So the output is showing 120.

0, but it should be 120.

00, and the 10.

0 should be 10.

00.

The error on this programme is on line 36.

So we have a print statement which uses an f-string.

The payment and change variables were initialised as floats by assigning them as float values earlier in the programme.

By default, Python displays float values without a fixed number of decimal places.

To ensure two decimal places in the output, you must format the float using string formatting.

Let's go and see how we can do this.

So to correct the error, the f-string in the print statement needs to be updated as follows.

So we now have print, open bracket, f to represent the f-string, and then we open our speech marks, and we have the message we want to display, which is "Thank you for your payment of", and then a pound sign, and then in our curly brackets, we have payment, which is the variable which is holding the payment value.

And then this time you can see we have a colon, a full stop, and then 2f, and then we close our curly bracket.

The full stop 2f ensures the number is displayed with exactly two decimal places.

So if we now have a look at the output for this, we have the correct format.

So we have, "Thank you for your payment of 120 pounds," with both zeros after the decimal point, and then, "Your change is 10 pounds." Again, in the correct format.

The programme can be tested with different inputs to check for errors.

A test table helps track expected versus actual outcomes.

So you can see here we have a test planned, test number one.

The input is going to be three people, two days, one car, and payment of 200 pounds.

The expected output is that the total will be 160, and the change will be 40.

The actual output is exactly that.

So total is 160, and change is 40.

So this test has passed.

Test two, though, has failed, because the expected output did not match the actual output.

So let's have a look at this test.

This time we're having two people.

We've put days as -1, cars as one, and payment as 50.

The expected output is that we should have an error message, because people can't select -1 days.

But the actual output was, "Thank you for your payment for 50 pounds.

Your change is 90 pounds." So this has failed the test.

Time to check your understanding.

What is the purpose of testing a programme with different inputs? Is it A, to make the programme run faster? B, to check for errors? Or C, to change the program's output? Pause the video whilst you have a think.

Did you select B? Well done.

The purpose of testing a programme with different inputs is to check for errors.

Sometimes, some inputs may work, whilst others won't.

Okay, we're now moving on to our second set of tasks for today's lesson, and you're doing a fantastic job so far, so well done.

Use the test table template provided to plan tests for your theme park ticket booking programme.

Remember to include different inputs in your plan.

So here we have the table template, and in the input we have people, days, cars, and payment.

You can repeat this line and change those numbers to test your programme fully.

Carry out the tests in your test table and record the results.

Pause the video whilst you complete the activities.

For part three, if any of your tests failed, make amendments to ensure your programme works correctly.

How did you get on? Did you manage to test your programmes? Well done.

Let's have a look at some sample output together.

Remember, your test results may look different from mine because your programmes will be different, but this is just to give you an idea of what you may have completed.

So for test number one, I used the input one person, one day, no cars, and payment of 30 pounds.

The expected output was that the total would be 25 pounds, and the change would be five.

The actual output was exactly that, so that test passed.

For test two, I put people to zero, days to two, cars to one, and payment to 50.

The expected output is an error message, because no one is going, so we've got zero people, which doesn't make sense.

The actual output was, "Thank you for your payment of 50 pounds, your change is 40 pounds." So that test has failed, and I'm gonna have to go back to my programme and make some corrections to stop that from happening.

Okay, we've come to the end of today's lesson, and you've done a fantastic job.

I hope you've managed to get your programmes working correctly, and you've managed to test them and fix any errors.

Let's summarise what we've learned in today's lesson.

Implementation is the process of creating a programme based on a design.

Testing is used to ensure that the programme works correctly.

Effective testing involves using different data to check for errors and ensure the programme behaves as expected.

I hope you've enjoyed this lesson, and I hope you'll join me again soon.

Bye!.