ICT - Block 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

Data Loging

In This Block, We’ll Discuss:


 Algorithm
 Flowchart
 Pseudo Code
 Scratch

OCTOBER 23, 2024


David Emanoueel Elraheb – Grade 8B
ICT Study sheet For Block 2 (2024 / 2025)
Week 1 – Unit 2

Software Development Cycle


The Software development life cycle is the name of the overall process of developing software from
start to finish.
The following are the key stages of the cycle:
1. Requirements - also known as the analysis stage. This is the first step, when the team decide what
the software needs to do.

2. Design - The team work out the details of the program by breaking it down into smaller chunks.
This includes thinking about the visual appearance and the programming behind the software. The
team will use pseudocode and diagrams to work out how the program should go.

3. Implementation - The Program Code is written. Good Pseudocode allows the implementation
stage to be relatively easy. The code is normally written in a high-level language.

4. Testing - This involves testing the program under various conditions to make sure it is going to
work. You need to think about what devices it could be used on and what might cause the
program to crash.

5. Evolution - The software is ready to be launched, but after it has been launched you will need to
think about how the software evolves. Software needs to be maintained to ensure it works on new
systems.

Page 1 of 17
Algorithm
It refers to a set of rules/instructions that step-by-step define how a work is to be done in order to get
the expected results.

When planning the program, you need to do the following:


1) Write the algorithm
2) Draw the flowchart
3) Write the program
4) Test the program

Here’s an Example:
Let us have a look at a typical student morning. We will look at how we approach our morning as a
series of different individual tasks.

Go to School Wake Up
Algorithm
Step 1: Wake up
Step 2: Get out of bed
Step 3: Have breakfast Get out of bed Get out of bed
Step 4: Go to school

Wrong as it’s not in the


Correct Order Have breakfast Have breakfast

Wake Up Go to School

Correct as it’s in the


Correct Order

The order in which we do each task is very important. If we get the order around the wrong way,
the tasks will not make sense.

Page 2 of 17
Flowchart “F.g. 2.1” shows more information, so this means it’s better and more informative, more
than Flowchart “F.g. 1.1”.

Flowchart “F.g. 1.1” Flowchart “F.g. 2.1”

Wake Up Wake Up Have Breakfast

Get out of bed Get out of bed Get SchoolBag

Have breakfast Ge Dressed Catch the Bus

Go to School Get into the kitchen Go to School

Before you write an algorithm, it’s important to check that the problem is completely understood.
There are a number of basic things you need to know in order to really understand the problem:

1. What are the inputs into the problem?


2. What will be the outputs of the problem?
3. In what order do instructions need to be carried out?
4. What decisions need to be made in the problem?
5. Are any areas of the problem repeated?

Once these basic things are understood, it is time to design the algorithm

Page 3 of 17
Flowchart
A flowchart is a picture (graphical representation) of an algorithm or the problem-solving process, it
gives a step – by – step procedure for a solution of a problem and it’s a formal plan for planning.

The Uses of Flowchart:


 To specify the method of solving a problem
 To plan the sequence of a computer program
 Communicate ideas and solutions

When Drawing a flowchart, you need to:


1. Identify the input and output
2. Apply reasoning skills to solve problems
3. Draw the flowchart using appropriate symbols and arrows to show the sequence of steps in
solving the problem

Simple Diagram of a flowchart:

Page 4 of 17
Flowchart symbols and their purpose:

Symbol Geometric shape Purpose (Use)


Oval is used to indicate the start and end
Oval Shape
of a flowchart.
Used for: (Start – End)

A parallelogram is used to read data


Parallelogram Shape
(input) or to print data (output).
Used for: (Input – Output)

A rectangle is used to show the


Rectangle Shape processing that takes place in the
Used for: (Process) flowchart

A diamond with two branches is used to


Diamond Shape Yes show the decision-making step in a
Used for: (Selection – flowchart. A question is specified in the
decision – Question - diamond. The next step in the sequence is
Branch) No based on the answer to the question
which is “Yes” or “No”.
Arrows are used to connect the steps in a
Arrows flowchart, to show the flow or sequence
Used for: (Connection) of the problem-solving process

Page 5 of 17
PseudoCode

Pseudocode is kind of structured English for describing the steps needed to solve a programming
task. It allows the designer to focus on the logic without being distracted by details of the
programming language.

Common PseudoCode Notation

There is no strict set of standard notations for pseudocode, but some of the most widely recognised are:

1 INPUT – indicates a user will be inputting something

2 OUTPUT – indicates that an output will appear on the screen

3 WHILE – a loop (iteration that has a condition at the beginning)

4 FOR – a counting loop (iteration)

5 REPEAT – UNTIL – a loop (iteration) that has a condition at the end

6 IF – THEN – ELSE – a decision (selection) in which a choice is made any instructions that
occur inside a selection or iteration are usually indented.

Common Arthimetic Operators

Type of Operation Symbol


Assignment ← or =
Comparison =-≠-<->-≤-≥
Arthimetic + , - , * , / , mod

Use of Psuedo Code

Pseudocode can be used to plan out programs. Planning a program that asks people what the best
subject they take is

Page 6 of 17
What is the difference between Constant and Variable?

Constant:

 Is a value in computer programming that does not change when the program is running.
 Is a location in memory that holds a value that cannot be changed as the program runs like π .

Variable:

 Is a symbol or name that stands for a value. Program instructions may cause the value to change.
 A named storage location containing a value that can change, depending on conditions during the
program’s execution

Example of PseudoCode:

REPEAT
OUTPUT 'What is the best subject you take?'
INPUT user inputs the best subject he takes
STORE the user's input in the answer variable
IF answer = 'Computer Science' THEN
OUTPUT 'Of course it is!'
ELSE
OUTPUT 'Try again!'
UNTIL answer = “Science”

Page 7 of 17
Structured Programming

Structured programming is a program written with only the structured programming constructions:

(1) Sequence:

This means that the computer will run your code in order, one line at a time from the top to the bottom
of your program. It will start at line 1, then execute line 2 then line 3 and so on till it reaches the last
line of your program.

(2) Repition / Alteration / Loop:


Sometimes you want the computer to execute the same lines of code several times. This is done using a
loop. There are three types of loops: For loops, while loops and repeat until loops.

Page 8 of 17
(3) Selection / Branch / Condition / Decision:
Sometimes you only want some lines of code to be run only if a condition is met, otherwise you want
the computer to ignore these lines and jump over them. This is achieved using IF statements.

Page 9 of 17
Converting Between Algorithms, PseudoCodes and Flowcharts

1st Algorithm 3rd FlowChart

=Step 1: Start
Step 2: Read A
Step 3: Read B
Step 4: Calculate Total = A + B
Step 5: Print Total
Step 6: Stop

2nd Pseudo Code

INPUT A
INPUT B
Add A and B INTO Total
OUTPUT Total

__________________________________________________________________________________

Task (2):

Create a Project in screatch to calculate the result of adding A to B

Here’s an evidence of it Working by adding A = 5 and B = 8, Equals to the Total = 13

Page 10 of 17
Week 1 – Unit 2 – Studysheet 2

Logo

Computers can be used to control many types of devices like robots. Robots need to be programmed
with instructions to tell them what to do and these need to be written in languages like Logo

Logo is a Simple Computer programming language which can be used to control devices. For
example, a small robot known as a turtle can be moved around the floor using logo. Logo is often used
with a screen turtle, which is an object on the screen used to simulate how a turtle moves around the
floor. There are many commands which can be used to control the turtle

LOGO Commands

Here are some examples of the most common Logo commands: (n / t = any value)
Command Function / Action
FORWARD n move forward n steps
BACKWARD n move backward n steps
LEFT t turn t° left
RIGHT t turn t° right
PENDOWN lower pen and begin drawing
PENUP raise pen and cease drawing
REPEAT n
Commands between these lines should be repeated n times
END REPEAT

These commands can be used to draw a square on the screen:


1. FORWARD 100
2. LEFT 90
3. FORWARD 100
4. LEFT 90
5. FORWARD 100
6. LEFT 90
7. FORWARD 100
8. LEFT 90

Page 11 of 17
Repeating commands
The same commands can be written more quickly using the REPEAT command, for example:
1. REPEAT 4
2. FORWARD 100
3. LEFT 90
4. END REPEAT

These above commands would have the same effect as the eight individual commands above - it draws
a square

The REPEAT command can be used to create any number of patterns. For example, a shape similar to
a Spirograph was created with these commands:

1. REPEAT 30
2. FORWARD 100
3. RIGHT 156
4. END REPEAT

Storing a series of commands like this creates a simple program. The order of the commands in a
program is vital. If it is in the wrong order, the program will not work as expected.

Computer programming languages are very fussy. Any errors, however small, will cause the program
not to work. The computer won't like spelling mistakes or, for example, if you forget to put a space
between FORWARD and 50.

Page 12 of 17
Example (1):
1 PENDOWN
2 FORWARD 60
3 RIGHT 90
4 FORWARD 60
5 RIGHT 90
6 FORWARD 30
7 RIGHT 90
8 FORWARD 30
9 LEFT 90
10 FORWARD 30
11 RIGHT 90
12 FORWARD 30

Example (2):
This Shape has two solutions:

Solution (1) Solution (2)


1 PENDOWN 1 PENDOWN
2 FORWARD 30 2 REPEAT 4
3 RIGHT 90 3 FORWARD 30
4 FORWARD 30 4 RIGHT 90
5 RIGHT 90 5 END REPEAT
6 FORWARD 30 6 FORWARD 30
7 RIGHT 90
8 FORWARD 30

Page 13 of 17
Example (3):
1 PENDOWN
2 FORWARD 40
3 RIGHT 90
4 FORWARD 20
5 PEN UP
6 FORWARD 10
7 PENDOWN
8 FORWARD 20
9 RIGHT 90
10 FORWARD 40
11 RIGHT 90
12 FORWARD 20
13 PEN UP
14 FORWARD 10
15 PENDOWN
16 FORWARD 20

Page 14 of 17
Week 2 – Studysheet 1 - Unit 2

Programming Constructs / Control Structure


Programs are designed using common building blocks. These building blocks, known as programming
constructs, form the basis for all programs.

There are three basic building blocks to consider:


 Sequence
 Selection / Decision / Condition / Branching
 Iteration / Repition / Loop

Sequence is the order in which instructions occur and are processed.


Selection determines which path a program takes when it is running.
Iteration is the repeated execution of a section of code when a program is running.

All programs use one or more of these constructs. The longer and more complex the program, the
more these constructs will be used repeatedly.

Page 15 of 17
1st let’s talk about Sequence:
Sequence is the first programming construct. In programming, instructions are executed one after
another. Sequence is the order in which the instructions are executed.
The sequence of instructions is extremely important as carrying out instructions in the wrong order
results in a program performing incorrectly.

Example of sequence:
1. Create a basic and Simple Calculator
Flowchart Design

Start

Get Number 1

Get Number 2

Total = Number 1
+ Number 2

Display Total

End
Scratch Script Blocks

Page 16 of 17

You might also like