# 2022-23 CSEC IT SBA Word Processing Marks (11th,22nd, Jan 2023)

Marks were assigned on 11th Jan 2023 for groups 1 and 2 and 22nd Jan 2023 for groups 3,4,5.

# Form 5 Opt C CSEC 2022 (Thu 6th Jan 2022)

`https://youtu.be/Kr8tyBU4SEg`

# Form 4 – Adding common website elements (11th Jan 2022)

See video below:

`https://youtu.be/fiv75dM_VXE`

# Ways of representing algorithms

There are several ways in which algorithms can be represented:

1. Narrative form : An algorithm can also be represented using narrative form, such as English or another human language. This representation is often used to describe algorithms in a way that is easy for humans to understand, but it can be difficult to translate into a programming language.

2. Pseudocode: Pseudocode is a way of representing an algorithm using a combination of natural language and programming language constructs. It is often used to represent algorithms in a way that is easy for humans to understand, but that can also be easily translated into a programming language.
3. Flowcharts: A flowchart is a graphical representation of an algorithm that uses symbols to represent different parts of the algorithm, such as input, output, decision-making, and loops. Flowcharts are often used to represent algorithms in a way that is easy for humans to understand and visualize.

#### Narrative form

Narrative form is a way of representing an algorithm using a story or a sequence of events. This representation is often used to describe algorithms in a way that is easy for humans to understand, but it can be difficult to translate into a programming language.

For example, an algorithm for sorting a list of numbers could be represented in narrative form as follows:

2. Compare the first two numbers in the list. If the first number is larger than the second number, swap their positions.
3. Compare the second and third numbers in the list. If the second number is larger than the third number, swap their positions.
4. Continue comparing and swapping pairs of numbers until the end of the list is reached.
5. Repeat the process until the list is sorted in ascending order.

Here is an example of an algorithm in narrative form that explains the steps for using a menu system to withdraw money from an ATM:

1. Start at the main menu of the ATM.
2. Choose the “Withdraw” option from the menu.
3. Enter the amount of money you want to withdraw.
4. Confirm the amount of money you want to withdraw.
5. If the ATM has enough money to dispense the requested amount, it will dispense the cash and return to the main menu. If the ATM does not have enough money, it will display an error message and return to the main menu.
6. If you want to make another transaction, return to the main menu and choose a different option. If you are finished, choose the “Exit” option from the menu to end the transaction and return to the main menu.

Narrative form is often used to describe algorithms in a way that is easy for humans to understand, but it is not as precise as other forms of representation, such as pseudocode or programming language.

#### Pseudocode

Pseudocode is a way of representing an algorithm using a combination of natural language and programming language constructs. It is often used to represent algorithms in a way that is easy for humans to understand, but that can also be easily translated into a programming language.

Here is an example of pseudocode for calculating the simple interest on a loan:

START CalculateSimpleInterest(principal, rate, time)

INPUT: float principal, float rate, float time

OUTPUT: float interest

interest <- principal * rate * time

RETURN interest

END

This pseudocode represents an algorithm that calculates the simple interest on a loan given the principal amount, interest rate, and time period. It starts by calculating the interest as the product of the principal, rate, and time. It then returns the value of interest as the output of the algorithm.

In this pseudocode, principal, rate, and time are the input variables, and interest is the output variable. The keyword START indicates the start of the algorithm, and the keyword END indicates the end of the algorithm. The keyword INPUT specifies the input variables, and the keyword OUTPUT specifies the output variable. The keyword RETURN is used to return the output of the algorithm.

#### Flowchart

Flowchart symbols are graphical symbols used to represent different parts of an by showing the flow from one step to another. Here are some common flowchart symbols and their meanings:

1. Oval or Circle: The oval or circle symbol represents the start or end of an algorithm.
2. Rectangle: The rectangle symbol represents a process step or action.
3. Diamond: The diamond symbol represents a decision point or branching point in the algorithm. It is used to represent a decision that must be made, with different branches leading to different outcomes based on the decision.
4. Arrow: The arrow symbol represents the flow of the algorithm and is used to connect different symbols in the flowchart.
5. Parallelogram: The parallelogram symbol represents input or output in the algorithm.
6. Terminal: The terminal symbol represents the start or end of a subprocess within the main algorithm.
7. Process: The process symbol represents a process step that involves some kind of manipulation or calculation.
8. Predefined Process: The predefined process symbol represents a process step that involves using a predefined function or procedure.
9. Off-page Connector: The off-page connector symbol represents a connection to a separate page or subprocess within the main algorithm.

Flowchart symbols are used to represent the different steps and decisions in an algorithm in a way that is easy for humans to understand and visualize. They are an important tool for representing algorithms and are widely used in a variety of fields.

### Algorithms compared

Here is a table showing the advantages and disadvantages of algorithms represented in different forms:

As you can see, each form of representation has its own advantages and disadvantages. The form that is most suitable for a given situation will depend on the needs and goals of the person representing the algorithm.

 TA-Note

# Python Example: Indefinite prompting to determine the corresponding grade for a given mark

Create a program that would repeatedly prompt the user for a mark and outputs the corresponding grade.

## Solution using discrete selection statements

```confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
while (confirm.lower() =="y" ):
#processdata here
print("fail")
print("D")
print("C")
print("B")
else:
print ("A")

#end dataprocessing
confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
print("end")

```

## Solution using cascading/nested selection statements

```confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
while (confirm.lower() =="y" ):
#processdata here
print("fail")
print("D")
print("C")
print("B")
print ("A")

#end dataprocessing
confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
print("end")

```

# The purpose of an algorithm

Algorithms are really intended as a blueprint for communication to programmers.

## Example: Finding the area of a circle

Problem Definition: A solution is needed to find the area of a circle given a radius.

Solution as a flowchart

Solution in pseudocode:

```START
//variable declaration
float area
float pi  = 3.14

//input

//processing

//output
print "The area is : ", area

END```

Actual program code in C:

```#include <stdio.h>
#include <stdlib.h>

int main()
{
const float pi = 3.14;
//input

//processing
printf ("\nThe area is : %f", area);

return 0;
}

```

Notice how similar the pseudocode is to the actual coded solution.

# Finding the Average of 5 numbers using Looping

Accept 5 numbers from a user and output the average.

## Solution using a for loop ## Solution using a while loop

Note: The task requires bounded iteration, a while loop is not ideal in principle however it can be done. Excel File

1. Download the attached Excel file and complete the tasks listed in the sheet TUTORIAL TASKS. The Tasks are to be completed in sheet 1. Note, these tasks must be accomplished in Microsoft Excel and not google sheets. (SEE ATTACHED VIDEO INSTRUCTIONS).

3. Rename your File in the format “Last name, First name – Excel Exam”

3. Attach this file to to assignment and turn in your  submission before the deadline date.

## Video instructions

```https://youtu.be/YWw4rJDwKv0
```

# Fillable Forms (CSEC Tutorial in Microsoft Word)

`https://youtu.be/HnudH-ApOoM`

Students to follow along with the video, using Microsoft word to –
1. Enable the developer tab.
2. Create a fillable form
3. Create a submit button : Submit A word processing form Via email

## Optional content

Can you create a fillable form using google forms? Reproduce the fillable form from the example using google forms if you can.

## Homework

Read and practise the example from Information Technology for CSEC – 3rd edition, Howard Campbell, pg 154-157.