← ict
Unit 6: FUNDAMENTALS OF PROGRAMMING
1.2 File Management p.7
vi
UNIT
ORGANIZATION OF FILES
UNIT OUTCOMES
At the end of this unit, learners will be able to:
Explain the file management system.
Analyze extensions of file types.
Organize, delete and restore files and folders.
Summarize file formats.
Convert a file into different formats.
Dear student, in grade 9, you learned about file management and related concepts
such as files, folders, file drivers, methods of file creation, naming and renaming
files and folders, and ways of accessing drives. In this unit, you are going to learn
advanced concepts of file management such as file types, extensions, drivers and
paths. You will also learn about methods of file conversion, saving and deleting
files, file backup and recovery, storage drive and mechanisms of file importing
and exporting.
Brainstorming
1. How are files handled at your home?
2. Can you describe ways of managing files in school or other organizations?
Before the introduction of automation system, schools and other societies used
to manage and organize their sensitive data in traditional file systems such filing
cabinets. Such systems are so traditional and complicated to access files.
Figure 1.1 shows a filing cabinet.
6.2 Basics of Algorithm p.211
UNIT
FUNDAMENTALS OF PROGRAMING
UNIT OUTCOMES
At the end of this unit, learners will be able to:
Explain concepts of algorithms.
Describe the representation of algorithms.
Discuss Integrated Development Environment (IDE).
As it was defined and discussed in grade 9, problem-solving steps are used to solve
day-to-day problems and make strategies to handle different situations which
keep arising in day-to-day life. One method of solving problems in computer
science is using algorithms. In this unit, you are going to learn basics of algorithm,
definition of algorithm, characteristics of algorithm, algorithm representation
and introduction to Integrated Development Environment (IDE).
Brainstorming
1. What do you recall by the term algorithm?
2. How do you verify problem solving concept?
Algorithm is a step-by-step process of solving a well-defined computational
problem. In practice, to solve any complex real-life problems, first we have to
define the problem and then design an algorithm to solve it. Writing and executing
a simple program may be easy; however, for executing a bigger one, each part of
the program must be well organized. In short, algorithms are used to simplify the
program implementation.
Computers are dumb machines because they do only what they are asked
to do. In computers, programs are developed to solve some problems. These
programs can be written using some computer programming languages like
Basic, C, C++, Java and Python.
In this section, you will develop your understanding of problem-solving and
its approaches.
To solve the problem using computers, we must follow the steps described below.
a. The problem must be analyzed thoroughly.
b. Solution method is broken down into a sequence of small tasks.
c. Based on this analysis, an algorithm must be prepared to solve the
problem.
d. The algorithm must be expressed in precise notation.
e. In viewing algorithm, a computer program has to be designed in any
high-level language.
f. The computer program is fed into the computer.
g. The instruction in the program executes one after another and outputs
the expected result.
For example, calculate the sum of two numbers, A and B, and store the sum in
C; here A and B are the inputs, addition is the process and C is the output of the
program, as shown in Figure 6.1.
Figure 6.1 Sum of two numbers
Activity 6.1
Answer the following activities accordingly.
1. Write the steps you may follow to do an everyday activity. It could be riding
a bike, making a sandwich or cooking “shiro wot”.
ii. Discuss the steps you have written with your friend.
iii. Can you provide the name for the steps you have written above?
6.3 Definition of Algorithm p.213
2. Explain the relationship between problem solving and algorithms.
3. Describe the steps for solving a problem in computers.
Brainstorming
1. Explain the term algorithm?
2. Can you state the benefits of using algorithms?
An algorithm is a precise method of solving a problem. It consists of a sequence
of unambiguous, step-by-step instructions. A program is an algorithm that has
been converted into program code so that it can be executed by a computer. A
well-written algorithm should be free from logic errors and easy to code in any
high-level language. Some of the most widely used definitions of an algorithm
are described hereunder.
An algorithm is a set of rules for carrying out calculations either by hand
or a machine.
An algorithm is a finite step-by-step procedure to achieve a required
result.
An algorithm is a sequence of computational steps that transform the
input into the output.
Let us conceptualize the concept of an algorithm by taking the example of
cooking “doro wot” for the first time as a new recipe. To cook a new recipe,
one reads the instructions and steps, and executes them one by one in the given
sequence. The result, thus, obtained is that the new dish cooked perfectly.
Similarly, algorithms help to do a task in programming to get the expected
output. The algorithms designed are language-independent; that is, they are just
plain instructions that can be implemented in any programming language and
yet the output will be the same. The components of an algorithm are described in
Figure 6.2 below.
Figure 6.2 Description of the algorithm
Before a computer can be put to any meaningful use, the user must be able to
define a unit sequence of operations or activities which are logically ordered as
an unambiguous method of solving a problem or finding a solution to it, which
is termed as an algorithm.
The term algorithm means “a process or set of rules to be followed in
calculations or other problem-solving operations”. Therefore, algorithm refers
to a set of rules/instructions that define step-by-step how a work is to be executed
to get the expected results.
Grade 10 Ict (new curriculum) p.215
One would not follow any written instructions to cook a recipe, but only the
standard one. Similarly, every written instruction for programming is not an
algorithm. For some instructions to be an algorithm, they must have the following
characteristics. It should be:
Clear and unambiguous: The algorithm should be unambiguous. Each
of its steps should be clear in all aspects and must lead to only one
meaning.
Well-defined inputs: If an algorithm says to take inputs, they should be
well-defined.
Well-defined outputs: The algorithm must clearly define what output
will be yielded and it should be well-defined as well.
Finiteness: The algorithm must be finite, i.e. it should not end up in
infinite loops or similar.
Feasible: The algorithm must be simple, generic and practical so that it
can be executed upon the available resources. It must not contain some
future technology or anything.
Language independent: The algorithm designed must be language-
independent, i.e. it must be just plain instructions that can be implemented
in any language, and yet the output will be the same as expected.
Activity 6.2
Do the following activities in a group.
1. Establish a group of three and choose problems that can be solved stepwise.
2. Relate the steps you have identified to the components of an algorithm.
3. Discuss the characteristics of an algorithm.
Advantages of algorithm
It is easy to understand.
Algorithm is a stepwise representation of a solution to a given problem.
In the algorithm the problem is broken down into smaller pieces or
steps; hence, it is easier for the programmer to convert it into an actual
program.
Disadvantages of algorithm
Writing an algorithm takes a long time, so it is time-consuming.
Branching and looping statements are difficult to show in algorithms.
Examples of algorithm
Let us consider a few examples of creating an algorithm for a given problem.
Example 1: Algorithm for the sum of two numbers
Step 1: Take the first number from the user (input).
Step 2: Take the second number from the user (input).
Step 3: Add the two numbers to get the sum (process).
Step 4: Display the sum on the screen (output).
Example 2: Write an algorithm to check whether the entered number is positive,
negative or zero.
Step 1: Take the number from the user.
Step 2: If the number is less than 0, then display that the entered number
is negative.
Step 3: If the number is greater than 0, display that the entered number
is positive.
Step 4: Otherwise, display that the entered number is zero.
Example 3: Calculate the sum of ten natural numbers.
The formula for the sum of ten natural numbers is sum = ∑ number i
i=1
Step 1: Let the sum be initially set to 0.
Step 2: Let i will be initially 1.
Step 3: Take the ith number from the user.
6.5.1 Flowchart Method p.217
Step 4: Add the ith number to the sum.
Step 5: Increase the value of i by 1.
Step 6: Check if the value of i is less than 10; then go to step 4. Otherwise,
go to step 7.
Step 7: Output the sum.
KEY CONCEPTS
An algorithm is a precise method of solving a problem. It consists of a
sequence of unambiguous, step-by-step instructions.
An algorithm is described in terms of input, process and output activities.
The characteristics of an algorithm include well defined input, well defined
output, clarity and unambiguity, fineness, language independence and fea-
sibility.
A program is a set of instruction written to carry out a particular task so that
computer can follow them.
Using algorithms for solving problems has both advantages and
disadvantages.
Some of the advantages of using algorithm are easy to solve a prob-
lem, practice step wise representation of problems and convert the al-
gorithm into actual program or code the programmer.
The disadvantages of using algorithms are time consuming for design-
ing and difficulty to show branching and looping statements
Brainstorming
1. How do you think algorithms are represented?
2. Discuss with your classmate what is meant by the flowchart.
3. State the benefits of using algorithms.
In computer programming, we wish to be able to create algorithms in a way that
will allow for easy translation to programming languages. Natural languages are
too imprecise to be used in algorithms that are to be used in computer program-
ming.
We need a way to describe our algorithms in a precise manner with a well-
defined syntax and clear, unambiguous semantics. There are two main ways in
which algorithms can be represented; they are flowcharts and pseudo code.
An algorithm can be described using many techniques and tools. One tool for
designing an algorithm is by using a flowchart. A flowchart is a graphical or
schematic representation of the major steps of work in a process. It displays the
essential steps of the program in separate boxes and shows the directions of
information flow using arrows. The boxes are most often referred to as illustrative
symbols and may represent documents, machines or actions taken during the
process. The area of concentration is on where or who does what, rather than on
how it is done. A flowchart can also be said to be a graphical representation of an
algorithm; that is, it is a visual picture that gives steps of an algorithm and flow
of control between the various steps.
Basic Flowchart Symbols
Flowcharts are drawn with the help of symbols. The following are the most com-
monly used flowchart symbols and their functions as shown in Figures 6.4 below
6.5 below. Let us start drawing a flowchart for a given problem. p.219
Figure 6.4 Flowchart symbols
Example 1: Consider a simple general flowcharting technique as shown in Figure
Figure 6.5 Flowchart techniques
Here different flowchart symbols are shown and are interconnected by the flow
line; start, input, processing, decision, predefined process, output and terminator
are interconnected.
Example 2: Draw a flow chart of an algorithm to add two numbers and display
their result.
Solution:
Algorithm description:
a. Read the rules of the two numbers (A and B).
b. Add A and B.
c. Assign the sum of A and B to C.
d. Display the result (C).
A flowchart is a picture of the separate steps of a process in sequential order. It is
a generic tool that can be adapted for a wide variety of purposes and can be used
to describe various processes such as manufacturing, administrative or service
and project plan.
Figure 6.6 Flow chart of an algorithm to add two numbers and display their result
1.2 Else Exit p.221
Example 3: Draw a flowchart to check if a given number is positive or negative.
Solution:
Algorithm description
a. Read a number x.
b. If x is less than zero, write a message negatively; otherwise write a
message that is not negative.
Flowchart
Figure 6.7 Flowchart that checks whether a given number is positive or negative
Sometimes there are conditions in which it is necessary to execute a group of
statements repeatedly until some condition is satisfied. This condition is called
a loop. Loop is a sequence of instructions that is repeated until some specific
condition occurs. A loop normally consists of four parts. These are:
Initialization: Setting of variables of the computation to their initial
values and setting the counter for determining to exit from the loop.
Computation: Processing
Test: Every loop must have some way of exiting from it or else the
program would endlessly remain in a loop.
Increment: Re-initialization of the loop for the next loop.
Example 3: Write the algorithmic description and draw a flowchart to find the
sum of the first 50 natural numbers as stated: Sum = 1+2+3+…. + 50
Solution:
Algorithmic description
1. Initialize sum to zero (0) and counter to 1.
Add counter to sum.
Increase counter by 1.
Repeat the above steps.
2. Write the sum
Flowchart
Figure 6.8 Flowchart showing the sum of the first 50 natural numbers
6.5.2 Pseudocode p.223
In this example, we can draw a simple flowchart for the sum of the first 50 natural
numbers. Therefore, we need flowchart symbols for input, output, process,
decision, start and end. The first and the last symbols are starting and end of the
flowcharting respectively. An initial sum of numbers is assumed to be zero which
is inputted in the input symbol.
The sum is added to the number, which is initialized as zero. The decision
block used in the flowchart takes the decision when the number is equal to 50 if
not then the natural number is incremented by one and added to the sum. This
process continues until the number counter goes up to 50. If the number is 50,
then the final sum will be calculated and displayed using the output symbol.
Activity 6.3
Answer the following activities in a group in a class.
1. Discuss the use of a flowchart.
2. List symbols used in the flowchart diagram with their description.
3. Describe the flow chart symbol used to indicate the decision.
Pseudocode is a program design aid that serves the function of a flowchart in
expressing the detailed logic of a program. Sometimes a program’s flowchart
might be inadequate for expressing the control flow and logic of the program.
Using pseudocode, the program’s algorithm can be expressed as English-
language statements. These statements can be used both as a guide when
coding the program in a specific language and as documentation for review by
others. Because there is no rigid rule for constructing pseudocodes, the logic of
the program can be expressed in a manner without confronting any particular
programming language. A series of structured words are used to express major
program functions. Let us see examples of pseudocode.
Example 1: Write the pseudocode to find the sum of two numbers.
Figure 6.9 Pseudocode for finding the sum of two numbers
Activity 6.4
Answer the following activities individually.
1. Explain the benefits of using pseudocode in problem-solving.
2. Describe the pseudocode for area and perimeter of a circle.
3. Demonstrate how the pseudocode method relates to flowchart design.
KEY CONCEPTS
An algorithm can be described using many techniques and tools. The two
main tools of designing algorithm are using flowchart and pseudocode.
A flowchart is a graphical or a schematic representation of the major steps
of work in a process. A flowchart symbols include start, input, process,
decision, terminators and flow line.
Pseudocode is a program design aid that serves the function of a flowchart
in expressing the detailed logic of a program.
6.6.1 Definition of an IDE p.225
Brainstorming
1. Can you explain what an IDE is?
2. Describe the benefits of using an IDE.
Software is a large component of our lives these days. If you do not agree, just
look around. Software is in the computers that sit on our desks in schools. It is
in our televisions and stereos. It is even in the mobile devices we carry around
like phones and tablets. These items have computers in them and computers
need software to run. In a technology-based world such as ours, it is inescapable.
Therefore, it should not come as a surprise that we need some means to create
this software. An introduction to Integrated Development Environment (IDE) is
a means to do this that puts everything we need at our fingertips.
An IDE enables programmers to consolidate different aspects of writing
a computer program. IDEs increase programmer productivity by combining
common activities of writing software into a single application: editing source
code, building executable, and debugging. In the next section, you learn the
formal definition of an IDE.
Figure 6.10 IDE for Java and Python programming
An integrated development environment (IDE) is an application that facilitates
application development. IDEs are designed to encompass all programming tasks
in one application. Therefore, IDEs offer a central interface featuring all the tools
a software developer needs, including the following functionalities as shown in
Figure 6.11.
Figure 6.11 Functionalities of an IDE
Common Features of Integrated Development Environments
An IDE typically contains a code editor, a compiler or interpreter, and a debugger
accessed through a single graphical user interface (GUI). The user writes and
edits source code in the code editor. The compiler translates the source code
into a readable language that is executable for a computer. The debugger tests
the software to solve any issues or bugs. The fundamental features of IDE are
discussed in the following.
Code editor : This feature is a text editor designed for writing and
editing source code. Source code editors are distinguished from text ed-
itors because they enhance or simplify the writing and editing of code.
Figure 6.12 Code editor
6.6.2 Benefits of Using IDEs p.227
Text editors : Virtually every IDE will have a text editor designed to
write and manipulate source code.
Figure 6.13 Text editors for IDE
Debugger : This tool is used during testing to help debug application
programs.
Build automation tools :These tools automate common developer tasks.
In addition, some IDEs might also include the following:
y Class browser: This tool is used to examine and reference the
properties of an object-oriented class hierarchy.
y Object browser: This feature is used to examine the objects
instantiated in a running application program.
Class hierarchy diagram: This tool allows the programmer to visualize
the structure of object-oriented programming code.
Note that IDE may be a stand-alone application or may be included as part of one
or more compatible applications.
Activity 6.5
Discuss the following activities in a group.
1. Describe the need for an IDE.
2. Explain three names of code and text editors you have learned.
3. Compare and contrast code and text editors.
The overall goal and main benefit of an integrated development environment
are improved developer productivity. IDEs boost productivity by reducing setup
time, increasing the speed of development tasks, keeping developers up to date
and standardizing the development process.
Faster setup :Without an IDE interface, developers would need to spend
time configuring multiple development tools. With the application
integration of an IDE, developers have the same set of capabilities in
one place, without the need for constantly switching tools.
Faster development tasks: Tighter integration of all development tasks
improves developer productivity. For Example, code can be parsed and
syntax checked while being edited, providing instant feedback when
syntax errors are introduced. Developers do not need to switch between
applications to complete tasks. In addition, the IDE’s tools and features
help developers organize resources, prevent mistakes and take shortcuts.
Further, IDEs streamline development by encouraging holistic thinking.
They enforce developers to think of their actions in terms of the entire
development lifecycle, rather than as a series of discrete tasks.
Continual learning: Staying up to date and educated is another benefit.
For instance, the IDEs topics are constantly being updated as well as
new samples, project templates, etc. Programmers who are continually
learning and with current best practices are more likely to contribute
value to the team and the enterprise, and boost productivity.
Standardization: The IDE interface standardizes the development
process which helps developers work together more smoothly and helps
new hires get up to speed more quickly.
6.6.3 Different Types of IDE p.228
There are a variety of different IDEs, catering to many different ways developers
work and different types of code they produce. Some IDEs are designed to
work with one specific language, cloud-based IDEs, IDEs customized for the
development of mobile applications or HTML and IDEs meant specifically for
Apple development or Microsoft development.
Grade 10 Ict (new curriculum) p.229
Multi-language IDE
Multi-language IDEs such as Eclipse, NetBeans and Komodo support multiple
programming languages.
Figure 6.14 IDE software
Eclipse:Supports C++, Python, PHP, Java and more. This free and open-
source editor is model for many development frameworks. The eclipse
began as a Java development environment and has expanded through
plugins. Eclipse is managed and directed by the Eclipse.org Consortium.
NetBeans: Supports Java, JavaScript, PHP, Python, Ruby, C, C++ and
more. This option is also free and open source. All the functions of the
IDE are provided by modules that each provide a well-defined function.
Support for other programming languages can be added by installing
additional modules.
IDE for a specific application
IDE for mobile development: There are IDEs specifically used for
mobile development, for instance, Android Studio and Visual Studio.
HTML IDE: Some of the most popular IDEs are those for developing
HTML applications. For Example, IDEs such as HomeSite, DreamWeaver
or FrontPage automate many tasks involved in website development.
Cloud-based IDE: Cloud IDEs give developers access to their code
from anywhere. For Example, Nitrous is a cloud-based development
environment platform that supports more than 40 languages including
PHP, Ruby, Python, JavaScript with Node.js and Go.
KEY CONCEPTS
An Integrated Development Environment (IDE) is an application that
facilitates application development. IDEs are designed to encompass all
programming tasks in one application.
An IDE typically contains a code editor, a compiler or interpreter and a
debugger which is accessed through a single graphical user interface (GUI).
Code editor: This feature is a text editor designed for writing and editing
source code.
Text editors: Text editor in IDEs are designed to write and manipulate source
code.
Source code editors are distinguished from text editors because they enhance
or simplify the writing and editing of code.
Compiler: This is a tool that transforms source code written in a human
readable or writable language into a form executable by a computer.
The benefits of using IDEs are faster setup, fast development tasks,
continuous learning and standardization of the development process.
Multiple IDEs such as Eclipse, NetBeans and Komodo support multiple
programming languages whereas IDEs for specific applications are IDEs
for mobile development, for instance Android Studio, Visual Studio, HTML
IDEs such as HomeSite, DreamWeaver or FrontPage, and Cloud-based IDE
such as PHP, Ruby, Python, JavaScript with Node.js and Go.
6.7 Unit Summary p.230
Flowcharts, decision tables, pseudocodes and algorithms are essential ingredients
to the writing of good programs. If they are done properly, they lead to a reduction
of errors in programs. They help minimize the time spent in debugging. In
addition, they make logic errors easier to trace and discover.
A flowchart is a graphical representation of the major steps of work in the
process. It displays the essential steps of the program in separate boxes and
shows the directions of information flow using arrows. Pseudocode is a program
design aid that serves the function of a flowchart in expressing the detailed logic
of a program.
6.8 Unit Review Exercise p.231
An algorithm is a precise method of solving a problem. It consists of a sequence
of unambiguous, step-by-step instructions. A program is an algorithm that has
been converted into program code so that it can be executed by a computer. A
well-written algorithm should be free from logic errors and easy to code in any
high-level language.
An IDE, or integrated development environment, enables programmers to
consolidate the different aspects of writing a computer program. It increases
programmer productivity by combining common activities of writing software
into a single application: editing source code, building executables and debugging.
The overall goal and main benefit of an integrated development environment
are improved developer productivity. IDEs boost productivity by reducing setup
time, increasing the speed of development tasks, keeping developers up to date
and standardizing the development process.
Eclipse supports C++, Python, PHP, Java and more. This free and open-
source editor is model for many development frameworks. The eclipse began as
a Java development environment and has expanded through plugins. NetBeans
supports Java, JavaScript, PHP, Python, Ruby, C, C++, and more. This option is
also free and open source. All the functions of the IDE are provided by modules
that each provide a well-defined function.
Grade 10 Ict (new curriculum) p.233
7. The graphical representation of algorithm is _________________.
A.program
B. flowchart
C.statement
D.algorithm
8. All instructions are executed one after the other.
A.Looping
B. Selective
C.Sequence
D.None of the above
9. The correct order of executing algorithms is ____________.
A.input process output
B. input output process
C.output process input
D.process input output
10. The part of a loop structure that describes processing is called ________.
A.initialization
B. computation
C.testing
D.increment
11. An abbreviation IDE stands for ___________.
A.individually determined environment
B. indented development entity
C.integrated development environment
D.integrated dynamic entity
← መጻሕፍት