# Data validation

It is really important to make sure that you do as much as you can to avoid user error in your programs. Data validation has been touched on a little throughout Part 1 and Part 2 of the programming units. In this lesson you will take this a step further by applying data validation through iteration.

Quiz:

# Intro quiz - Recap from previous lesson

Before we start this lesson, let’s see what you can remember from this topic. Here’s a quick quiz!

## Question 3

Q1.What will be the output when this program is executed?

1/3

Q2.When using the range() function. What is the first parameter used for? e.g. range(1, 11, 2)

2/3

Q3.When using the range() function. What is the second parameter used for? e.g. range(1, 11, 2)

3/3

Quiz:

# Intro quiz - Recap from previous lesson

Before we start this lesson, let’s see what you can remember from this topic. Here’s a quick quiz!

## Question 3

Q1.What will be the output when this program is executed?

1/3

Q2.When using the range() function. What is the first parameter used for? e.g. range(1, 11, 2)

2/3

Q3.When using the range() function. What is the second parameter used for? e.g. range(1, 11, 2)

3/3

# Video

Click on the play button to start the video. If your teacher asks you to pause the video and look at the worksheet you should:

• Click "Close Video"
• Click "Next" to view the activity

Your video will re-appear on the next page, and will stay paused in the right place.

# Worksheet

These slides will take you through some tasks for the lesson. If you need to re-play the video, click the ‘Resume Video’ icon. If you are asked to add answers to the slides, first download or print out the worksheet. Once you have finished all the tasks, click ‘Next’ below.

Quiz:

# Data Validation

Don’t worry if you get a question wrong! Forgetting is an important step in learning. We will recap next lesson.

## Question 3

Q1.If the following code was used as a validation check on, how many times could a user enter incorrect data before the program had a runtime error?

1/3

Q2.A user is asked to enter a number between 1 and 20. They enter 21. What type of validation error would this cause?

2/3

Q3.The following code is used as a validation check to ensure that a whole number is entered. On which line will the loop terminate?

3/3

Quiz:

# Data Validation

Don’t worry if you get a question wrong! Forgetting is an important step in learning. We will recap next lesson.

## Question 3

Q1.If the following code was used as a validation check on, how many times could a user enter incorrect data before the program had a runtime error?

1/3

Q2.A user is asked to enter a number between 1 and 20. They enter 21. What type of validation error would this cause?

2/3

Q3.The following code is used as a validation check to ensure that a whole number is entered. On which line will the loop terminate?

3/3

# Lesson summary: Data validation

### Time to move!

Did you know that exercise helps your concentration and ability to learn?

For 5 mins...

Move around:
Walk

On the spot:
Chair yoga

### Take part in The Big Ask.

The Children's Commissioner for England wants to know what matters to young people.