Loading...
Hello, my name's Mrs. Jones, and I'm really pleased you decided to join this lesson today.
In this lesson, we will be looking at project design and looking at two different ways to create structured designs for programmes, and these ways are flowcharts and pseudocode.
So let's get started.
Welcome to today's lesson.
Today's lesson is called "Project design" from the unit Python programming project.
And by the end of this lesson, you'll be able to create a structured design for a programming project.
There are two keywords to today's lesson.
Flowchart.
Flowchart is a diagram that uses symbols to document the logic of an algorithm.
Pseudocode.
Pseudocode is a way of expressing an algorithm that is independent of a specific programming language.
There are two sections to today's lesson.
The first is create a flowchart and the second is create pseudocode.
So let's start with create a flowchart.
In a flowchart, the logic and flow of an algorithm is expressed visually using arrows and shapes.
And you can see here in this example with the start, then output "What is your name?", input user_name, output welcome_message, and end.
Note the shapes and note the arrows.
And we're going to have a look at what they mean and how we're going to put those together.
A flowchart is a diagram used to illustrate the steps of an algorithm.
Flowcharts are made up of symbols, each containing a single step of the algorithm.
The terminal symbol marks the start and end of the flowchart.
And you can see here the start and end written inside, and it is this specific shape.
A well-designed flowchart should have only one entry and one exit point.
The rectangle symbol represents a process, and this represents an operation or a set of operations that changes the value, form, or location of data.
The arrow symbol represents the direction of flow from one step to the next.
Flow is assumed to be from top to bottom and from left to right.
If flow is nonstandard, arrowheads need to be added.
The diamond symbol represents a decision.
You can see two examples here, one with yes and no, and one with true and false.
A decision is a conditional operation that will determine which one of two paths the programme will take.
The symbol usually contains a yes/no question, or a true or false test.
The parallelogram symbol represents an input or output.
This symbol indicates the process of taking an input into the system or outputting data from the system.
A rectangle with two lines inside represents a sub-program.
This indicates a named process that is defined elsewhere.
This could be a function that performs a specific task.
Flowcharts can be useful tools for a number of reasons, such as providing visual clarity to complex problems, checking logic and steps before writing code, providing excellent documentation for processes.
Note that for simple programmes, a flowchart may not be needed and could add to development time.
Sometimes the programme code itself might be clear enough without a flowchart.
Let's have a quick check.
In a flowchart, which symbol is used to represent an input or output? Is it A, the diamond; B, the oval; C, the parallelogram? Pause the video to consider your answer and then we'll check it.
Let's check your answer.
The answer was C, the parallelogram.
Well done if you got that correct.
Over the course of this project, you'll be developing a computer programme for a project called StreamScheduler, which will help a content creator plan their game review stream.
A content creator is preparing a live stream where they review a series of upcoming games to people online.
They want a computer programme that will help them to plan the duration of their stream.
The programme will last for the total duration of the stream and how long they will spend reviewing each game.
Once the total review time reaches the planned stream duration, the schedule is complete.
Let's have a look at the StreamScheduler flowchart.
1.
1 was user inputs the total duration of the stream in minutes, and you can see that in the flowchart as the first step after the start.
It is a parallelogram because the user is inputting something, input stream_duration.
2.
1, validate that the total duration is between 20 and 40 minutes.
So now we have a decision.
Is duration valid? Is it between 20 and 40 minutes? And there's a yes or no output.
So on the flowchart, the no would go back around to ask them to input the duration again, or if it is yes, it carries on to the next step.
2.
2, store the total duration of the stream.
And then 2.
3, convert the total duration to seconds.
And you can see that in that step, that process there, we're going to convert the minutes to seconds.
The second flowchart will represent the second step of the programme.
Number two is to add game reviews: allow the user to enter the games to review and how long each review will take.
So let's have a look here.
We have the inputs, which is 1.
2, the user inputs the name of each game to be reviewed.
1.
3, user inputs the review duration for each game in seconds.
Processes, we've got 2.
4, store the name of the game being reviewed and the duration.
2.
5, store the running total of games reviewed.
2.
6, validate that running total has not exceeded total duration.
2.
7, stop asking for more games once total review time is equal to the stream duration.
So let's have a look at the flowchart.
Well, first off, we start by setting up a variable, total_time = 0.
We need to create a list for game names and we need to create a list for game review durations.
Then we've got the inputs, input the game_name, input the review_seconds, and then there's the first decision.
Is review_seconds less than stream_duration? And there's a yes or no output there.
No would go back around to enter review_seconds, and yes would carry on to add game name to the list.
Add review_seconds to list and add review_seconds to total time, all of those are processes as they're making changes.
This will then move to the decision, is review_seconds less than stream_duration? If the answer is yes, it goes to the end and it finishes.
If not, it will go back up.
Let's have a quick check.
A flowchart is: A, a written description to show how to solve a problem; B, a computer programme to solve a problem; C, a visual diagram that uses symbols to show how to solve a problem.
Pause the video to consider your answer and then we'll check it.
Let's check your answer.
The answer was C, a visual diagram that uses symbols to show how to solve a problem.
Well done if you got that correct.
Let's do the activity.
There are two more steps to represent using a flowchart.
Three, choose a random giveaway time: randomly select a time to show the giveaway discount code during the stream.
Four, display the stream details: display the full stream schedule, including each game and the amount of time to review it and the prize giveaway time.
Based on the requirements provided, draw a flowchart to represent the final steps of the programme.
Pause the video, go back through the slides, use your worksheet, and have a go at creating the flowchart to represent those final steps of the programme, and then we'll go through the solution.
Let's have a look at the solutions.
So we have start, import random library, create giveaway_time, randomly generate a time between one and total stream seconds, convert giveaway_time to minutes and seconds.
All of those are processes.
And then we have an output, output giveaway_time, end.
Well done if you got that correct.
Let's move to the second part of today's lesson, create pseudocode.
The word pseudocode can be broken down into two parts.
Pseudo means pretend or fake.
Code refers to the instructions written in a programming language.
The word pseudocode literally means pretend code.
Unlike flowcharts, there are no set standards or conventions that must be used for pseudocode.
This means that the style and conventions used for pseudocode may differ for each GCSE exam board.
Whatever style of pseudocode is used, it is important to be consistent and make sure that the meaning is clear.
Let's have a quick check.
The word pseudocode literally means: A, code that a computer can understand; B, pretend code or fake code; C, a diagram for showing the sequence of a code; C, a diagram for showing the sequence of a programme.
Pause the video to consider your answer and then we'll check it.
Let's check your answer.
The answer was B, pretend code or fake code.
Well done if you got that correct.
When writing pseudocode, keywords are often capitalised.
For example, INPUT, PRINT, WHILE, FOR, IF-THEN-ELSE.
Note that there are many other keywords that are used in pseudocode.
Pseudocode is a way of representing an algorithm using syntax that is independent of any particular programming language.
Programmers use pseudocode in a similar way as artists use sketches.
It is a quick and easy alternative to writing a whole programme in order to test a solution.
Pseudocode is often used to see if a solution is possible and logical before translating it into a final programme.
There are several reasons to represent algorithms using pseudocode, such as uses clear and concise language close to English, it's not tied to a particular programming language, it helps to spot and fix errors, and it can act as a blueprint and rough guide to final code.
Let's have a quick check.
True or false? Pseudocode cannot be executed by a computer.
Pause the video to consider if that is true or false and then we'll go through the answer.
Let's have a look at the answer.
The answer was true.
Pause the video to consider why that's true.
How would you explain that? And then I'll give an answer.
Let's have a look at the answer.
So why? Pseudocode must be translated into a real programming language, such as Python, Java, or C#, for it to be executed by a computer.
Well done if you got that correct.
In pseudocode, an algorithm is expressed using syntax that is independent of any programming language.
And we've got in capitals PRINT, and then in brackets, "What is your name?" Name equals, capitals there, INPUT, open and close brackets.
Then we've got capitals again PRINT, and inside we've got "Hello " + name.
Pseudocode is an effective way to represent algorithms because only a basic knowledge of programming is needed to read, write, and understand the logic.
Before attempting to represent an algorithm with pseudocode, it is important to understand the problem that needs to be solved.
The pseudocode on the next slide represents the following requirements to collect the stream duration.
Inputs: 1.
1 was user inputs the total duration of the stream in minutes.
And the processes: 2.
1, store the total duration of the stream, and 2.
2, convert the total duration to seconds.
So you can see here those 1.
1, 2.
1, and 2.
2 requirements.
We've got valid_duration = false, and what we've got here is WHILE valid_duration == false, we've then got duration = INPUT ("Enter the stream duration in minutes.") IF duration >= 20 and duration <= 40, THEN valid_duration = true.
ELSE it's going to print "Please enter a duration between 20 and 40." And then we have ENDIF.
And note the ENDIF.
Because we have IF and ELSE, we have that selection there, we're ending it, and it clearly shows that within our planning in our pseudocode.
The pseudocode on the next slide represents the following requirements to add game reviews.
So we've got the inputs: 1.
2, user inputs the name of each game to be reviewed, 1.
3, user inputs the review duration for each game in seconds.
And we've got the processes: 2.
3, store the name of the game being reviewed and the duration; 2.
4, store the running total of the games reviewed; 2.
5, validate that running total in between 20 and 40 minutes; and 2.
6, stop asking for more games once total review time is more than or equal to the stream duration.
So here you can see we've set up a list at the beginning.
So we've set up an empty list called game.
Total_time = 0.
And note the keywords, WHILE is being capitalised and INPUT, so WHILE total_time < stream_duration.
Got the game_name = INPUT ("Enter the game name: ").
Valid_review = false.
WHILE not valid_review, we've got review_seconds = INPUT ("Enter review duration in seconds: ").
IF review_seconds > stream_duration, then it's going to PRINT "Review time cannot be more than total stream duration.
Try again." ELSE it will go valid_review = true.
games.
APPEND((game_name, review_seconds)).
Total_time += reviewseconds.
ENDWHILE.
And then it says PRINT ("enough games added for the stream.").
The following requirements are to randomly choose a giveaway time and display schedule.
Processes: 2.
7, randomly select a time from total stream time to display discount code giveaway.
Outputs: 3.
1, display the total number of games reviewed; 3.
2, display the name and duration of each reviewed game; 3.
3, indicate the time when the discount code will be given away during the stream; and 3.
4, display the total planned stream duration in minutes and seconds.
Let's do the activity.
Based on the requirements provided, write the pseudocode to represent those final steps of the programme.
Pause the video, go back through the slides, and have a go at writing the pseudocode to represent the steps of the programme, and then we'll go through the solution.
Let's have a look at the solution.
So we have PRINT ("Stream Summary:").
Counter = 1.
Giveaway_time = 0.
FOREACH game IN games: name = game, we have the position in the list.
Duration = game, position in the list.
Print(counter + name + " - " + duration + " seconds").
IF counter == giveaway_index, print(">>> GIVEAWAY CODE DISPLAYED HERE <<<").
Counter += 1 and then NEXT game.
Well done if you got that correct.
In summary, structured design is the process of planning a programme in detail before you start to write any code.
This design stage is essential for developers to understand the program's requirements and how it will function.
Tools like flowcharts provide a visual representation of a program's logic, while pseudocode offers a text-based step-by-step description of its operation.
Designing a programme this way helps to prevent mistakes, saves time, makes the final code easier to write and understand.
Well done for completing this lesson on project design.