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

Higher Nationals

Internal verification of assessment decisions – BTEC (RQF)

INTERNAL VERIFICATION – ASSESSMENT DECISIONS

Program title Programming

Assessor Internal Verifier

Unit(s)

Assignment title
M.A.M.AFRI
Student’s name

List which assessment Pass Merit Distinction


criteria the Assessor has
awarded.

INTERNAL VERIFIER CHECKLIST

Do the assessment criteria awarded


match those shown in the
assignment brief? Y/N

Is the Pass/Merit/Distinction grade


awarded justified by the assessor’s Y/N
comments on the student work?

Has the work been assessed


accurately? Y/N

Is the feedback to the student:


Give details:
• Constructive?
• Linked to relevant assessment
criteria? Y/N
• Identifying opportunities for Y/N

M.A.M.AFRI 1
improved performance? Y/N
• Agreeing actions? Y/N

Does the assessment decision need


amending? Y/N

Assessor signature Date

Internal Verifier signature Date

Program Leader signature (if


required) Date

M.A.M.AFRI 2
Confirm action completed

Remedial action
taken

Give details:

Assessor signature Date

Internal
Verifier Date
signature

Program Leader
signature (if Date
required)

Higher Nationals - Summative Assignment Feedback Form

Student Name/ID 00083957/M.A.M.AFRI

Unit Title Programming

Assignment Number 1 Assessor

Date Received
Submission Date 1st submission

Date Received 2nd


Re-submission Date submission
Assessor Feedback:

LO1. Define basic algorithms to carry out an operation and outline the process of programming an applicati

Pass, Merit & Distinction Descripts P1 M1 D1

LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, con
analysis of a suitable Integrated Development Environment (IDE).

Pass, Merit & Distinction Descripts P2 M2 D2

M.A.M.AFRI 3
LO3. Implement basic algorithms in code using an IDE.

Pass, Merit & Distinction Descripts P3 M3 D3

LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 M4 D4

Grade: Assessor Signature: Date:

Resubmission Feedback:

Grade: Assessor Signature: Date:

Internal Verifier’s Comments:

Signature & Date:

* Please note that grade decisions are provisional. They are only confirmed once internal
and external moderation has taken place and grades decisions have been agreed at the
assessment board.
Assignment Feedback
Formative Feedback: Assessor to Student

Action Plan

Summative feedback

M.A.M.AFRI 4
Feedback: Student to Assessor

Assessor Date
signature

Student Date
signature

Pearson Higher Nationals in


Computing

Unit 01: Programming


Assignment 01
General Guidelines
1. A Cover page or title page – You should always attach a title page to your
assignment. Use previous page as your cover sheet and be sure to fill the details
correctly.
2. This entire brief should be attached in first before you start answering.
3. All the assignments should prepare using word processing software.

M.A.M.AFRI 5
4. All the assignments should print in A4 sized paper, and make sure to only use one
side printing.
5. Allow 1” margin on each side of the paper. But on the left side you will need to leave
room for binging.

Word Processing Rules


1. Use a font type that will make easy for your examiner to read. The font size should be
12 point, and should be in the style of Time New Roman.
2. Use 1.5-line word-processing. Left justify all paragraphs.
3. Ensure that all headings are consistent in terms of size and font style.
4. Use footer function on the word processor to insert Your Name, Subject,
Assignment No, and Page Number on each page. This is useful if individual sheets
become detached for any reason.
5. Use word processing application spell check and grammar check function to help edit
your assignment.

Important Points:
1. Check carefully the hand in date and the instructions given with the assignment. Late
submissions will not be accepted.
2. Ensure that you give yourself enough time to complete the assignment by the due
date.
3. Do not leave things such as printing to the last minute – excuses of this nature will not
be accepted for failure to hand in the work on time.
4. You must take responsibility for managing your own time effectively.
5. If you are unable to hand in your assignment on time and have valid reasons such as
illness, you may apply (in writing) for an extension.
6. Failure to achieve at least a PASS grade will result in a REFERRAL grade being
given.
7. Non-submission of work without valid reasons will lead to an automatic REFERRAL.
You will then be asked to complete an alternative assignment.
8. Take great care that if you use other people’s work or ideas in your assignment, you
properly reference them, using the HARVARD referencing system, in you text and
any bibliography, otherwise you may be guilty of plagiarism.
9. If you are caught, plagiarizing you could have your grade reduced to A REFERRAL
or at worst you could be excluded from the course.

M.A.M.AFRI 6
Student Declaration

I hereby, declare that I know what plagiarism entails, namely to use another’s work and to
present it as my own without attributing the sources in the correct way. I further understand
what it means to copy another’s work.

1. I know that plagiarism is a punishable offence because it constitutes theft.


2. I understand the plagiarism and copying policy of the Edexcel UK.
3. I know what the consequences will be if I plagiaries or copy another’s work in any of
the assignments for this program.
4. I declare therefore that all work presented by me for every aspects of my program,
will be my own, and where I have made use of another’s work, I will attribute the
source in the correct way.
5. I acknowledge that the attachment of this document signed or not, constitutes a
binding agreement between myself and Edexcel UK.
6. I understand that my assignment will not be considered as submitted if this document
is not attached to the attached.

Student’s Signature: Date:


(afri77aa@gmail.com) (31/01/2022)

M.A.M.AFRI 7
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number M.A.M.AFRI/00083957

Unit Number and Title Unit 01: Programming

Academic Year 2021/22

Unit Tutor

Assignment Title Design & Implement a GUI based system using a suitable
Integrated Development Environment

Issue Date

Submission Date

IV Name & Date

Submission Format

This submission will have 3 components

1. Written Report

This submission is in the form of an individual written report. This should be written in a concise,
formal business style using single spacing and font size 12. You are required to make use of
headings, paragraphs and subsections as appropriate, and all work must be supported with research
and referenced using the Harvard referencing system. Please also provide a bibliography using the
Harvard referencing system. (The recommended word count is 1,500–2,000 words for the report
excluding annexures)

2. Implemented System (Software)


The student should submit a GUI based system developed using an IDE. The system should connect
with a backend database and should have at least 5 different forms and suitable functionality
including insert, edit and delete of main entities and transaction processing.

3. Presentation
With the submitted system student should do a presentation to demonstrate the system that was
developed. Time allocated is 10 to 15 min. Student may use 5 to 10 PowerPoint slides while doing
the presentation, but live demonstration of the system is required. Evaluator will also check the

M.A.M.AFRI 8
ability to modify and debug the system using the IDE.

Unit Learning Outcomes:

LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.

LO2. Explain the characteristics of procedural, object-orientated and event-driven


programming; conduct an analysis of a suitable Integrated Development Environment
(IDE).

LO3. Implement basic algorithms in code using an IDE.

LO4. Determine the debugging process and explain the importance of a coding
standard

M.A.M.AFRI 9
Assignment Brief and Guidance:

Activity 1

Searching on an array/list is to find a given element on the array and return whether it is found or
not and return its position if found. Linear search and binary search are two popular searching
algorithms on arrays.

1.1 Define what an algorithm is and outline the characteristics of a good algorithm. Develop
algorithms for linear search and binary search using Pseudo code.

1.2 Describe the steps involved in the process of writing and executing a program. Take an array
of 10 or more elements and dry run the above two algorithms. Show the outputs at the end of
each iteration and the final output.

1.3 Define what Big-O notation is and explain its role in evaluating efficiencies of algorithms.
Write the Python program code for the above two algorithms and critically evaluate their
efficiencies using Big-O notation.

Activity 2

2.1 Define what a Programming Paradigm means. Explain the main characteristics of Procedural,
Object oriented and Event-driven paradigms and the relationships among them.

2.2 Write small snippets of code as example for the above three programming paradigms using a
suitable programming language(s).

2.3 Critically evaluate the code samples that you have above in relation to their structure and the
unique characteristics.

M.A.M.AFRI 10
Activity 3 and Activity 4 are based on the following Scenario.

Ayubo Drive is the transport arm of Ayubo Leisure (Pvt) Ltd, an emerging travel & tour
company in Sri Lanka. It owns a fleet of vehicles ranging from cars, SUVs to vans.

The vehicles that it owns are hired or rented with or without a driver. The tariffs are based on the
vehicle type. Some of the vehicle types that it operates are, small car, sedan car, SVUs, Jeep
(WD), 7-seater van and Commuter van. New vehicle types are to be added in the future.

Vehicle rent and hire options are described below.

1. Rent (With or without driver) – For each type of vehicle, rates are given per day, per week
and per month. Rate for a driver also given per day. Depending on the rent period, the total
rent amount needs to be calculated. For example: if a vehicle is rented for 10 days with a
driver, total amount to be calculated as follows:

Total rent = weeklyRent x 1 + dailyRent x 3 + dailyDriverCost x 10

2. Hire (with driver only) – These are based on packages such as airport drop, airport pickup,
100km per day package, 200km per day package etc. Standard rates are defined for a
package type of a vehicle type if that is applicable for that type of vehicle. For each package,
maximum km limit and maximum number of hours are also defined. Extra km rate is also
defined which is applicable if they run beyond the allocated km limit for the tour. For day
tours if they exceed max hour limit, a waiting charge is applicable for extra hours. Driver
overnight rate and vehicle night park rate also defined which is applicable for each night
when the vehicle is hired for two or more days.

Activity 3

3
3.1 Design suable algorithms for vehicle tariff calculation for rents and hires.
Ideally 3 functions should be developed for this purpose as follows:

Function 1: Rent calculation.


Return the total rent value when vehicle no, rented date, return date, with driver parameters are

M.A.M.AFRI 11
sent in. with driver parameter is set to true or false depending whether the vehicle is rented with
or without driver.

Function 2: Day tour - hire calculation.


Calculate total hire_value when vehicle_no, package_type, start_time, end_time,
start_km_reading, end_km_reading parameters are sent in. Should return base_hire_charge,
waiting_charge and extra_km_charge as output parameters.

Function 3: Long tour - hire calculation.


Calculate total hire_value when vehicle_no, package_type, start_date, end_date,
start_km_reading, end_km_reading parameters are sent in. Should return base_hire_charge,
overnight_stay_charge and extra_km_charge as output parameters.

3.2 Implement the above algorithms using visual studio IDE (using C#.net) and design the
suitable database structure for keeping the tariffs for vehicle types and different packages
which must be used for implementing the above functions.

3.3 Analyze the features of an Integrated Development Environment (IDE) and explain how
those features help in application development. Evaluate the use of the Visual Studio IDE for
your application development contrasted with not using an IDE.

Activity 4

2
3
4
4.1 Design and build a small system to calculate vehicle hire amounts and record them in a
database for customer billing and management reporting for Ayubo drive. This includes the
completing the database design started in 3.2 and implementing one or more GUIs for
vehicle, vehicle type, and package add/edit/delete functions. It essentially requires an
interface for hire calculation and recording function described above. Generating customer
reports and customer invoices are not required for this course work.

4.2 What is debugging an application? Explain the features available in Visual studio IDE for
debugging your code more easily. Evaluate how you used the debugging process to develop

M.A.M.AFRI 12
more secure, robust application with examples.

4.3 Explain the coding standards you have used in your application development. Critically
evaluate why a coding standard is necessary for the team as well as for the individual.

M.A.M.AFRI 13
Grading Rubric

Grading Criteria Achieved Feedback

LO1 Define basic algorithms to carry out an operation


and outline the process of programming an application.

P1 Provide a definition of what an algorithm is and outline


the process in building an application.

M1 Determine the steps taken from writing code to


execution.

D1 Examine the implementation of an algorithm in a


suitable language. Evaluate the relationship between the
written algorithm and the code variant

M.A.M.AFRI 14
LO2 Explain the characteristics of procedural, object
orientated and event-driven programming, conduct an
analysis of a suitable Integrated Development
Environment (IDE)
P2 Give explanations of what procedural, object
orientated, and event driven paradigms are; their
characteristics and the relationship between them.

M2 Analyze the common features that a developer has


access to in an IDE.

D2 Critically evaluate the source code of an application


which implements the programming paradigms, in terms
of the code structure and characteristics.
LO3 Implement basic algorithms in code using an IDE.

M.A.M.AFRI 15
P3 Write a program that implements an algorithm using
an IDE.

M3 Use the IDE to manage the development process of


the program.

D3 Evaluate the use of an IDE for development of


applications contrasted with not using an IDE.

LO4 Determine the debugging process and explain the


importance of a coding standard

P4 Explain the debugging process and explain the


debugging facilities available in the IDE.

P5 Outline the coding standard you have used in your


code.

M4 Evaluate how the debugging process can be used to


help develop more secure, robust applications.

M.A.M.AFRI 16
D4 Critically evaluate why a coding standard is necessary
in a team as well as for the individual.

M.A.M.AFRI 17
Table of Contents
1.1 Algorithm..........................................................................................................................22
What is algorithm?...............................................................................................................22
Characteristics of a good algorithm are,..........................................................................22
Linear Search....................................................................................................................22
Binary Search....................................................................................................................23
1.2Linear Search in Python Programming..........................................................................24
1.3 Define What Big-O Notation...........................................................................................27
Efficiency Analysis............................................................................................................27
Binary Search in python programming................................................................................28
2.1 Programming Paradigms................................................................................................31
What is a programming paradigm?......................................................................................31
Imperative Programming Paradigm (Procedural)............................................................32
Structured Programming Paradigm.....................................................................................33
Functional Programming Paradigm......................................................................................33
• A huge program is broken down into small convenient procedures or functions.......33
• Different functions can share data through global variables........................................33
• Functions can change global data.................................................................................33
Top-down methodology...................................................................................................33
Advantages of procedural programming.........................................................................34
Restrictions or disadvantages of procedural programming.............................................34
The characteristics of Object Oriented programming are as follows,.............................35
A comparison between Procedural and Object Oriented Programming.............................36
The Characteristics of Event-driven Programming are as follows,......................................38
1.Events (Mouse, keyboard and user interface)..............................................................38
3.Local variables...............................................................................................................39
2.2. Using the Procedural and Imperative Programming Paradigms in Python
Language.................................................................................................................................41
Using the Object Oriented Programming Paradigms in Python Language. Object Oriented
Programming Characteristics...............................................................................................42

Encapsulation in python programming language................................................................45


Inheritance in python programming language....................................................................47

M.A.M.AFRI 18
Polymorphism in Python Programming
Language...................................................................................49

Event driven in Python Programming Language..................................................................51


Time driven even..............................................................................................................51
Key-pressEvents...............................................................................................................52
Mouse Events...................................................................................................................55
3.1Algorithms for vehicle tariff calculation for rents and hires.........................................56
Function 1: Rent calculation.................................................................................................56
Function 2: Day tour.............................................................................................................57
Function 3: Long tour...........................................................................................................59
3.2 Database structure for keeping the tariffs for vehicle types and different packages
and Console Applications......................................................................................................60
The Database structure for Packages is displayed below....................................................60
Packages Design...............................................................................................................61
Pacckages Data.................................................................................................................62
The Database structure for Vehicles is displayed below,....................................................63
Vehicle Design..................................................................................................................63
Vehicle Data.....................................................................................................................64
Console Application..........................................................................................................65
Rent Calculation...............................................................................................................66
The Output for Rent calculation,......................................................................................67
Day Tour...........................................................................................................................68
Long Tour..........................................................................................................................70
3.3 Integrated Development Environment (IDE)................................................................73
What is an IDE (Integrated Development Environment)?...................................................73
Text editor........................................................................................................................73
Debugger..........................................................................................................................73
Compiler...........................................................................................................................73
Code completion..............................................................................................................74
Programming language support.......................................................................................74
Integrations and plugins...................................................................................................74
4.1 The system to calculate vehicle hire amounts and record............................................75
Database record for customer billing and management reporting for Ayubo....................75
Login Interface..................................................................................................................75
Main Menu Interface.......................................................................................................76

M.A.M.AFRI 19
Package details interface......................................................77
Vehicle Details Interface.......................................................78

Rent Calculation Interface................................................................................................79


Day Tour Interface............................................................................................................80
Long tour interface...........................................................................................................81
Backend Code for Rent Calculation..................................................................................82
Backend Code for Long Tour Calculation.........................................................................82
4.2 What is debugging an application?.................................................................................83
The debugging process,........................................................................................................83
Fix an exception................................................................................................................84
Break points......................................................................................................................85
4.3 Coding standards..............................................................................................................87
Use of Indentation............................................................................................................88
Using Variables.................................................................................................................89
Acknowledgement..................................................................................................................92
References...............................................................................................................................93

M.A.M.AFRI 20
Task 01

1.1 Algorithm

What is algorithm?
In computer programming, algorithms are often formed as functions. These functions serve
as small programs that can be referenced by a larger program. In many cases, there
are several ways to perform a specific operation within a software program. In general
term, An algorithm is defined as a set of instructions designed to perform a specific
task. Algorithms work via input and output. They take the input and apply each step of the
algorithm to that information to produce an output.

Characteristics of a good algorithm are,

• Input and output should be defined accurately.


• Each step in the algorithm should be clear and unmistakable.
• Algorithms should be most effective among many different ways to solve a
-problem.
• An algorithm should not contain computer code. Instead, the algorithm should be written
in -such a way that it can be used in different programming languages.

Linear Search
In Linear Search Algorithm method, we compare the elements of the array one By one with
the main element we are looking for in sequential order. The pseudo code for linear search
would be like as given below:
BEGIN
Index = 1
i=0
Found = False

M.A.M.AFRI 21
WHILE i < length(numlist) AND NOT found
IF numlist[i] == numSought then
Index = i
Found = True Endif
i=i+1
Endwhile
Return Index
END

Binary Search
The Binary Search Algorithm can only be applied on sorted data and works by finding the
middle element in a list of information, sometime recently choosing which side of the
information the required element is to be found within. The undesirable half of the data is at
that point rejected and the process is repeated until the required element is found or until it
is known that the required element does not exist within the data. The Time complexity of
linear search is “O (n)” The Pseudo code for Binary Search would like as given below ,

BEGIN
Low = 0
High = a.length -1
WHILE Low <= High:
Mid = (Low + High) / 2 IF
a[Mid] == b:
Return Mid
Else if a[Mid] > b:
High = Mid -1

Else:
Low = Mid + 1
Endif

M.A.M.AFRI 22
Endwhile
Return “Not found”
END

1.2Linear Search in Python Programming

Figure 1.1

Searching for Number “25” in the “array”


Iteration 1

5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9

Begins from the leftmost element of given array [] and one by one compare element
”a” with each element of array []

M.A.M.AFRI 23
Iteration 2

5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9

It continues either searching until the element “25” is found or all the elements are searched.

Iteration 3
5 10 15 20 25 30 35 40 45 50

0 1 2 3 4 5 6 7 8 9

Iteration 4
5 10 15 20 25 30 35 40 45 50

0 1 2 3 4 5 6 7 8 9

Iteration 5
5 10 15 20 25 30 35 40 45 50

0 1 2 3 4 5 6 7 8 9

Once”a” equals with any of the element, returns the index value

M.A.M.AFRI 24
Figure 1.2

M.A.M.AFRI 25
1.3 Define What Big-O Notation

Efficiency Analysis

Base Case The search ends in success The element being


with just one comparison. searched may be found at
the first position.

Worst Case The search terminates in The element being


success with “n” searched may be existing
comparisons. at the last position or not
exist in the array at all.

Average Cage (n + 1) /2 comparison

Big-O Notation = O(n)

M.A.M.AFRI 26
Binary Search in python programming

Figure 1.3

M.A.M.AFRI 27
Searching for Number “30” in the “array”
Iteration Low High Mid Found
1 0 9 4 No
2 5 9 7 No
3 5 6 5 Yes

Iteration 1
5 10 15 20 25 30 35 40 45 50

0 1 2 3 4 5 6 7 8 9

Iteration 2
5 10 15 20 25 30 35 40 45 50

0 1 2 3 4 5 6 7 8 9

Iteration 3
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9

Once”a” equals with any of the element, returns the index value

M.A.M.AFRI 28
Figur
e 1.4

Efficiency Analysis
Best Case 1 comparison Item found in the 1st middle
element

Worst Case Log 2 n comparison Searching for non-existing


elements

Average Case (Log 2n + 1) /2 Average of above 2


comparison

Big-O Notation = O(Log 2 n)

Activity 2

M.A.M.AFRI 29
2.1 Programming Paradigms

What is a programming paradigm?


Programming paradigm is a method to deal with problems using some programming
language or additionally we can say it is a strategy to solve a problem using tools and
methods that are accessible to us following some methodology. There are lots for
programming language that are well-known but all of them need to follow some
approaches when they are implemented and this methodology is paradigms.There are two
main programming paradigms, an Imperative and a Declarative, and there are numerous
paradigms that are inclined by these two types.

Figure 2.1.1

M.A.M.AFRI 30
Imperative Programming Paradigm (Procedural)

The main objective of the imperative programming paradigm development is to


decrease expenses of program development as well as maintenance. It is a style or
method of writing a program. A procedural programming paradigm is derived from
structured programming. It is based on the concept of the procedure call. Procedures are
also known as sequences, subsequences, approaches, or functions. A Procedure contains a
chain of instructions coupled to be carried out.
Imperative Programming Paradigm is related to two other paradigm

Figure 2.1.2

M.A.M.AFRI 31
Structured Programming Paradigm

Structured Programming means that the code will implement the instruction-by-
instruction one after the other. It does not support the possibility of skipping from one
instruction to some other with the assistance of any statement like GOTO and variables.

Functional Programming Paradigm

Functional Programming are specially designed to handle representative computation and


list processing applications. Functional programming is based on mathematical functions
and avoids changing state and variable data. The characteristics of Procedural
Programming are as follows,

• A huge program is broken down into small convenient procedures or functions.

This decreases code repetition, which improves read ability and maintainability of the code.

• Different functions can share data through global variables.

Functions are completely isolated; therefore, if we want to share data, we need to declare it
in the upper scope.

• Functions can change global data

In the mean-time global data are transferred from function to function; during the
progression of the transformation, the global data may be improved in function chains.

Top-down methodology.

Procedural programming follows the top-down approach; workflow is going from top to
bottom.
Below is an example of the main subroutine of a program coded using the procedural
paradigm.

M.A.M.AFRI 32
Advantages of procedural programming
1. The coding is easy and simple.
2. The codes have the capability to be reused in numerous parts of the program.
3. The programming paradigm consumes less memory on the computer.

4. It is easier for tracking the flow of the codes in the program written in the procedural
programming paradigm.
5. The programming paradigm is considered as the best for general programming to
learn and implement.

Restrictions or disadvantages of procedural programming


1. Concentrates on functions rather than data.
2. In a huge program, it is difficult to classify the belonging of global data.
3. The use of global data is error-prone and it could be a barrier in case of maintenance
and developments.
4. The modification of global data involves the modification of those functions using it.
Maintaining and improving the program code is still difficult because of global data.
5. The procedural programming paradigm does not model the real-world problem very
well since functions are action-oriented and do not really agree to the elements of the
problem. Object Oriented Paradigm.

Object-Oriented Paradigm is where we focus on real life objects while programming any
solution. The objective of an object-oriented program is to represent the real world in code.
In the object-oriented paradigm, the problem is divided into smaller parts called objects, and
systems are built around objects. Objects are depictions of things that exist in the real world
that we wish to model in a computer system.

M.A.M.AFRI 33
The characteristics of Object Oriented programming are as follows,

Figure 2.1.3

 Encapsulation

Encapsulation is taking data and keeping it securely from outside interfaces. These user
defined data types are called "classes," and one occasion of a class is an "object."

 Abstraction

The capability to represent data at a very theoretical level without any details.
Abstraction facilitates the easy conceptualization of real world objects, by excluding
the pointless details of the object.

M.A.M.AFRI 34
 Inheritance

The process by which a class can be derived from a base class with all features of base class
and some of its own. This escalates code reusability, Classes are created in hierarchies,
and inheritance allows the assembly and methods in one class to be distributed down
the hierarchy. That means less programming is necessary when adding functions to complex
systems.
 Polymorphism

This is the capability to exist in numerous methods, allows procedures about objects to be
formed whose precise type is not known until runtime.

A comparison between Procedural and Object Oriented Programming

Procedural Object Oriented


Uses immutable data Uses mutable data

Follows the declarative programming Follows the imperative programming


model model
Extends support to parallel programming Not appropriate for parallel programming

The execution order of statements is The execution of statements is very


not the primary focus important

Flow control is performed using function Flow control is performed through


calls conditional statements and loops

Uses recursion concept to iterate collective Uses loop concept to iterate collective data
data
No side effects of its functions The method can have side effects
The focus in procedural programming is The focus in object oriented programming
“What are you doing” is “How are you doing it

M.A.M.AFRI 35
Event-driven Programming Paradigms
Event-driven Programming is when a program is designed to respond to user
involvement in various forms. It is known as a programming paradigm in which the
flow of program implementation is determined by “Events”. Events are any user
interaction, such as a click or key press, in response to prompt from the system. Events are
checked by a code (function) known as an “Event listener”. If the event listener detects that
an allocated event has happened, it will prompt a callback function, known as an event
handler. As shown below is an example,

Figure 2.1.4

M.A.M.AFRI 36
The Characteristics of Event-driven Programming are as follows,

 Time driven

Time driven in event driven programming is a paradigm, it is the code that runs on a time
prompt, this could be a part of the code that runs at a particular time, which could be once a
week or whenever a program is launched, and this means it is a pre-set task.

 Event handlers

Event handler is a function that takes place when a certain event occurs, they are
implemented in response to a certain event that takes place, this can be on a
button, when a button is clicked the code is executed, if the button is clicked again after that
it will execute again, this is an event handler.

 Trigger functions

Trigger functions choose what code is executed when a particular event takes place,
they are used to choose when event handlers are executed for the event that took place, most
applications have a trigger function for each event that is probable to occur.

1. Events (Mouse, keyboard and user interface)

For the events inside a program to occur, they need to be generated, this is when the user
interacts with an object, which may be a button getting clicked by a mouse, events can be
generated in many different ways, it can be with your mouse, due to movement, left
clicking, right clicking or scrolling, the keyboard can also be used to begin events, this can
be from pressing certain keys, holding down certain keys or from being typed onto the
keyboard. The events occur due to code being assigned to something, for example
code might be assigned to a button, so when that particular button is clicked the code is
executed.

M.A.M.AFRI 37
•Pre-defined functions
A pre-defined function is a function that is built into the programming language. This can be
used as procedural so this code will run as soon as the program is ongoing, or you can
assign the code to a button, so that it can be triggered through an event.

3. Local variables
A local variable is a variable that is stated within a method, that variable will only be used
by the method where it is stated, other methods will not use it.

 Parameter passing

Parameter passing is used by a function, it tolerates a value to be passed through a


program, it can be used for many things, including an alarm or discovering a
certain character at a certain position, through on an alarm, the event doesn’t take place up
until a certain time has come, this is due to events.

Advantages of Event-driven Programming


 Flexibility

Event-driven can be changed easily if the programmer desires something to be


changed. This paradigm lets the programmer to create a form of their requirements.

 Appropriate for Graphical Interfaces

Event-driven allows the user to choose different tools from the toolbar to directly create
what they need such as buttons, radio buttons, etc.
This also let us to put objects wherever they want them to be and can directly edit. Some
find it easier to directly click on the object that they want to edit.

M.A.M.AFRI 38
 Effortlessness of Programming

Can make the programming easier is that when using an event driven language such as
visual basic it generally has predictive coding so when the user is coding it will suggest
what you want to do from what you are typing.

 Allows for more Interactive Programs

It allows for more interactive programs. Nearly all modern GUI programs use event driven
programming.

 Using Hardware Interrupts

It can be executed using hardware interrupts, which will decrease the power used by the
computer.

 Allows sensors and other hardware

It allows sensors and other hardware to effortlessly interact with the software.

Disadvantages / Constraints of Event-driven Programming


Complexity For simple programs, event-driven programming is often more complex.
Less Logical, The flow of the program is usually less logical.
Difficult to find Errors Errors can be more difficult to discover than with simpler,
procedural programs.

M.A.M.AFRI 39
 Slower

Programs with complex GUIs (Graphical User Interface) may be slower to load and run
than simpler program particularly if the RAM (Random Access Memory) is insufficient.
 Confusing

Programs with too many forms can be very confusing for the user.

2.2. Using the Procedural and Imperative Programming Paradigms in Python


Language.

Figure 2.2.1

I have reused the function “calculate total()” to calculate the “number_list1” and
“number_list2” total. The procedural style depends on procedure calls to create modularized
code. Which means you can use functions to group the parallel type of work and
makes the overall code simpler. And get the Output as shown below

M.A.M.AFRI 40
Figure 2.2.2

Using the Object Oriented Programming Paradigms in Python Language. Object


Oriented Programming Characteristics
 Classes and Objects
 Encapsulation
 Inheritance
 Polymorphism
 Class in Python Language

Figure 2.2.3

M.A.M.AFRI 41
In the above
 There is a Class named Student.
 Constructors have the default name” __init__”. They are functions that are indirectly
labelled when an object of the class is formed.
 All instance methods as well as the constructor have their first parameter as self.
 Self refers to instance that is being referenced while calling the method.
 “Name” and “age” are the instance variables.

M.A.M.AFRI 42
Figure 2.2.4

In the above:
 “S” is the name of the object that I’m creating based on Student class
 Even though the class has three parameters (self, name, age), I will still pass
only name and age while creating an object, as we don’t need to refer self here. It is
implicit.
 Once an object is formed, you can refer to the attributes of the object using a dot. For
example, s.name refers to the name attribute of that individual object.

M.A.M.AFRI 43
Encapsulation in python programming language

Figure 2.2.5

This the concept of wrapping data such that the outside world has access only to
unprotected properties. Some properties can be hidden to reduce exposure. This is an
execution of data hiding.
In Python, this is implemented by creating private, protected and public instance variables
and methods.
Private properties have double underscore (__) in the start, while protected properties have
single underscore (_). By default, all other variable and methods are public. Private
properties are available from within the class only and are not available for child class (if
inherited). Protected properties are accessible from within the class but are available to child
class too. All these constraints are removed for public properties. Given below is he Output,

M.A.M.AFRI 44
Figure 2.2.5

M.A.M.AFRI 45
Inheritance in python programming language

Figure 2.2.6

M.A.M.AFRI 46
In inheritance, another class (called subclass) inherits a “class”. The subclass adds some
attributes to superclass.

Shown below is the Output,

Figure 2.2.7

M.A.M.AFRI 47
Polymorphism in Python Programming Language

Figure
2.2.8

Can produce function that can take any object allowing for polymorphism

Figure 2.2.9

M.A.M.AFRI 48
Event driven in Python Programming Language

Time driven even

Figure 2.2.9

The turtle module in Python has a timer that can effect an event when its time is up. When
the event does happen, the handler is called, and shown below is the event when executed,

M.A.M.AFRI 49
Figure 2.2.10

Key-press Events

M.A.M.AFRI 50
Figure 2.2.11

It is needed to call the window’s listen method, or else it won’t respond to the key
presses.
The handlers can be randomly complex functions that call other functions.

M.A.M.AFRI 51
Pressing the “space” key on the keyboard calls function a4 (because it has been bounded to
a4). While executing a4, the window’s bye method closes the turtle window, which causes
the window’s “main loop” call to terminate its execution.
The keys can be referred on the keyboard by their character code. When the turtle window
opens, It enables “t” to move by pressing the arrow keys.

M.A.M.AFRI 52
Mouse Events

Figure 2.2.12

A mouse event is a bit different from a key press event because it’s handler needs two
parameters to receive a,b coordinate information telling where the mouse was when the
event happened.
This enables to move the turtle to an accurate coordinate position. So what this program
does is move the turtle (and draw a line) to anywhere the mouse is clicked on.

M.A.M.AFRI 53
Activity 3

3.1Algorithms for vehicle tariff calculation for rents and hires.

Function 1: Rent calculation.

Function

RentCalculation(RegNo,RentedDate,ReturnDate,WithDriver)

/*Calculate No of Elapsed Days

DateDiff=ReturnDate -RentedDate

/*calculate months,weeks,days

Months=DateDiff / 30

Remainder = DateDiff % 30

Weeks = Remainder / 7

Days = Remainder % 7

Find the required vehicle record from vehicle table If

(found)

Show VehicleType,MonthlyRate,WeeklyRate,DayRate,DriverRate

Amount= Months*MonthlyRate + Weeks*WeeklyRate + Days*DayRate


If(With_Driver == true)

Total_Amount= Amount+Date_Diff*DriverRate

Else

M.A.M.AFRI 54
Total_Amount=Amount

End if

Print("Total amount",total_amount")

Else

Print("Vehicle Not found")

End if

End function

Function 2: Day tour.

Function day tour (packageid.start_time,end_time,start_km,end_km) Find the required


record from package_table

If found()

Noofhours end_time-start_time If

no of hours max hors then

ex_hours-no_hours-max_hours

ex_hour_charge-ex_hours*ex_hour_rate

ex_hours 0 endif

M.A.M.AFRI 55
else ex_hour_charge-
ex_hours*ex_hour_rate:

no_of km end_km-start_km.

if(no_of km>max_km) ex_km=no_km

max km

else

ex_km=0

endif

ex_km_charge-ex_km*ex_km_rate

/ calculate total cost

total cost package_rate+ex_hour_chargete

x_km_rate print("total cost:",total_cost) else

print("record not found")

end if
end function

M.A.M.AFRI 56
Function 3: Long tour.

Function Long_tour(Pid,Start_date,End_date,Start_KM,End KM) Find the required record


from Package_table

If found()) nDays End_date


Start_date
NoofKM End-Start_KM

permitted KM-Max KM NoofDays

if(NoofKM permitted_KM)then

Ex KM-NoofKM-permitted_KM

else
Ex KM-0
Endif

ExKMCharge Ex KM * ExKMRate
Print("Extra KM Charge",EXKMCharge)

/"calculate Base hire"/


BaseHireCharge-PRate NoofDays
Print("Extra Base Hire Charge",BaseHireCharge)

M.A.M.AFRI 57
/"calculate Night Charge/
NightCharge(VehiNightRate + DrNightCharge) (NoofDays -1).
Print("Owner Night Charge",NightCharge)

Total cost BaseHireCharge + NightCharge + ExKMCharge


Print("Total cost "TotalCost)

Else
Print("Record Not Found")
Endif
End function

3.2 Database structure for keeping the tariffs for vehicle types and different packages
and Console Applications.

The Database structure for Packages is displayed below.

M.A.M.AFRI 58
Packages Design

Figure 3.2.1

M.A.M.AFRI 59
Pacckages Data

Figure 3.2.2

M.A.M.AFRI 60
The Database structure for Vehicles is displayed below,

Vehicle Design

Figure 3.2.3

M.A.M.AFRI 61
Vehicle Data

Figure 3.2.3

M.A.M.AFRI 62
Console Application

Figure 3.2.4

M.A.M.AFRI 63
Rent Calculation

Figure 3.2.5

The Output for Rent calculation,

Figure 3.2.6

M.A.M.AFRI 64
Day Tour

Figure 3.2.7

Figure 3.2.8

M.A.M.AFRI 65
Figure 3.2.9

Figu
re 3.2.10

M.A.M.AFRI 66
Long Tour

Figure 3.2.11

Figure 3.2.12

M.A.M.AFRI 67
Figure 3.2.13

M.A.M.AFRI 68
3.3 Integrated Development Environment (IDE)

What is an IDE (Integrated Development Environment)?

An integrated development environment (IDE) is a software suite that combines basic tools
necessary to write and test software. IDEs provide interfaces for users to write code,
organize text groups, and automate programming redundancies. IDE Common Features
are,

Text editor
Virtually every IDE will have a text editor designed to write and manipulate source
code. Some tools may have visual components to drag and drop front-end components, but
most have a simple interface with language specific syntax highlighting.

Debugger
Debugging tools support users in identifying and resolving errors within source code.
They often simulate real world scenarios to test functionality and performance.
Programmers and software engineers can usually test the various sections of code and
Identify errors before the application is released.

Compiler
Compilers are components that translate programming language into a form that
Machines can process, such as binary code. The machine code is analyzed to confirm
Its accuracy. The compiler then parses and optimizes the code to optimize performance.

M.A.M.AFRI 69
Code completion
Code complete features assist programmers by intelligently identifying and inserting
Common code components. These features save developers time writing code and
Reduce the possibilities of errors and bugs.

Programming language support


IDEs are normally specific to a single programming language, though several also offer
Multilanguage support. As such, the first step is to discover which languages it will be
coding in and narrow of the prospective IDE list down accordingly.

Integrations and plugins


With the name integrated development environment, it is no surprise that integrations need
to be considered when looking at IDEs. The IDE is the development portal, so being
able to include all the other development tools will improve development workflows
and productivity. Poor integrations can cause several issues and lead to many headaches, so
make sure to understand how well a potential IDE fits into the ecosystem
Of existing tools
.

M.A.M.AFRI 70
Activity 04

4.1 The system to calculate vehicle hire amounts and record

Database record for customer billing and management reporting for Ayubo.

Login Interface

Figure 4.1.1

M.A.M.AFRI 71
Main Menu Interface

Figure 4.1.2

M.A.M.AFRI 72
Package details interface

Figure 4.1.3

M.A.M.AFRI 73
Vehicle Details Interface

Figure 4.1.4

Rent Calculation Interface

Figure
4.1.5

M.A.M.AFRI 74
Day Tour Interface

Figure 4.1.5

Long tour interface

Figure 4.1.6

M.A.M.AFRI 75
Backend Code for Rent Calculation

Figure 4.1.7

Backend Code for Long Tour Calculation

Figure 4.1.8

M.A.M.AFRI 76
4.2 What is debugging an application?

Debugging is the process of identifying and eliminating of existing and potential errors (Also
called as ‘bugs’) in a software code that can cause it to behave unexpectedly or crash. To
prevent incorrect operation of a software or system, debugging is used to find and resolve
bugs or defects. When various subsystems or components are firmly coupled, debugging
becomes harder as any change in one component may cause more Bugs to appear in another.
Sometimes it takes more time to debug a program than to Code it.

The debugging process,

1. Reproduce the problem.


2. Describe the bug. Try to be as much input from the user to get the precise reason.
3. Capture the program snapshot when the bug appears. Try to get all the variable values and
states of the program at that time.
4. Examine the snapshot based on the state and action. Based on that try to find the
Cause of the bug.
5. Fix the existing bug, but also check that any new bug does not occur
 The features available in Visual studio IDE for Debugging,

When running the app in Visual Studio for the first time, we may start it by pressing the
Green arrow button Start Debugging in the toolbar (or F5). By default, the Debug value
Appears in the drop down to the left. If you are new to Visual Studio, this can leave the
impression that the debugging the app has something to do with running the app, which it
does, but three are two very different tasks.
Select a debug build

Figure 4.2.1

M.A.M.AFRI 77
A Debug value indicates a debug configuration. When we start the app (press the green arrow
or F5) in a debug configuration, we start the app in debug mode, which means we are running
the app with a debugger attached. This enables a full set of debugging features that can be
used to help find bugs in the app. If we have a project open, choose the drop-down
selector where it says Debug and choose Release instead. Select a Release build.

Figure 4.2.2

When we switch this setting, we change our project from a debug configuration to a
release configuration. Visual Studio projects have separate release and debug
configurations for our program. We build the debug version for debugging and the
release version for the final release distribution. A release build is optimized for
performance, but a debug build is better for debugging.

Fix an exception

When I have fixed all the red squiggles and resolved or at least investigated all the green
squiggles, I am ready to start the debugger and run the app. Press F5 (Debug > Start
Debugging) or the Start Debugging button Start Debugging in the Debug toolbar. At this
point, the sample app throws a Serialization Exception (a runtime error). That is, the app
blocks on the data that it is trying to serialize. Because I started the app in debug mode
(debugger attached), the debugger's Exception Helper takes you right to the code that threw
the exception and gives a helpful error message.

M.A.M.AFRI 78
Figure 4.2.3

Break points

I set breakpoints wherever you want to pause debugger execution. I can break execution
when a function is called. When i debug, execution pauses at the breakpoint, before the Code
on that line is executed. This is useful, for example, when you know the function Name but
not its location. It is also useful if you have functions with the same name and you want to
break on them all (such as overloaded functions or functions in different projects).

M.A.M.AFRI 79
Figure 4.2.4

M.A.M.AFRI 80
4.3 Coding standards

They are a series of measures that can be defined for a particular programming language
Specifying a programming style, the methods, & different procedures. These procedures Can
be for various characteristics of the program written in that language. They can be considered
as essential attributes of software development.a coding standard makes sure that all the
developers working on the project are following certain specified guidelines. The code
can be easily understood and proper consistency is maintained. Consistency has a positive
impact on the quality of the program and one should maintain it while coding. Also, it
should be taken care that the guidelines are consistently followed across different levels
of the system and they do not oppose each other. The finished program code should look like
that it has been written by a single developer, in a single session.

The coding standards that I have used in my application development are,

 Code Comments and Proper Documentation

It is a good practice to comment while writing code. It helps other developers to understand
your code. With the use of the Integrated Development Environment and other tools,
commenting can be utilized in many different ways. It is advisable to start every method or
routine with the comment specifying what a routine, method or a function does, about
its various parameters, its return values, errors and exceptions (if any). In addition, the role of
each file and class, their contents and even the steps of complex Codes should be summarized
in the comments.

Figure 4.2.5

M.A.M.AFRI 81
Use of Indentation

It is advisable to make use of indentation while writing the code. There is no particular style
defined, but any style can be chosen for writing code. However, a consistent
indentation style should be followed throughout the code. For Instance,

F
igure 4.2.6

Using Variables

Variables are the names I gave to computer memory locations, which are used to store values
in a computer program. In most or all software programming languages, variables work
like containers to hold numbers, phrases, or other important stuff used in numerous places in
my code.

M.A.M.AFRI 82
Figure 4.2.7

Why a coding standard is necessary for the team as well as for the individual. Coding
standards are a set of guidelines, best practices, programming styles and Conventions
that developers follow to when writing source code for a project. All big software companies
have them. A coding standards document tells developers how they must write their code.
Instead of each developer coding in their own preferred style, they will write all code to the
standards outlined in the document. This makes sure that a large project is coded in a reliable
style parts are not written differently by different programmers. Not only does this solution
make the code easier to understand, it also ensures that any developer who looks at the code
will know what to expect throughout the entire application.

Working Independently. In this case, programmer has to follow those coding standards
because the programmer needs to state an efficient well working computer application.
Because of that the inner logic of the program should be clearly stated, that means the code.
If the programmer works according to the coding standards, the code will be not only simpler
but also will be efficient too. When proper coding standards are used, there will be no
errors in the specific program. In that case, the testing stage will be easier. Because of that
the deployment process of the program will be efficient so the programmer can develop the
program within the given time period.

M.A.M.AFRI 83
When you start sharing code or start reading code shared by others, you begin to realize that
not everybody writes their code they way you do. You see that other, ugly coding style, and
think, “Everybody needs to write in the same style that I do so that things are easier to
understand.” Therefore, it is natural that everybody wants their own ways turned into the
standard, so they do not have to change their habits. If the entire team work according to a
specific coding standard, the combining process will be easier and the wastage of the time
will be decreased because of that. So if the programmers use same standards it will make
things much easier for the team. Likewise, the coding standards is not only important in
working as a team but also it benefits in working as individual as well.

M.A.M.AFRI 84
References
Available at:
https://medium.com/@bhattshlok12/characteristics-of-an-algorithm-49cf4d7bcd9
Accessed by (2022/01/23)

Available at:
http://neonbrand.com/procedural-programming-vs-object-oriented-programming-areview/
Accessed by (2022/01/23)

Available at:
https://www.edrawsoft.com/flowchart/program-flowchart-definition.html
Accessed by (2022/01/23)

Available at:
http://www.cs.cornell.edu/courses/cs482/2003su/handouts/pseudocode.pdfJacobson,
Accessed by (2022/01/23)

Available at:
https://blog.usejournal.com/how-to-write-pseudocode-a-beginners-guide-29956242698
Accessed by (2022/01/23)

Available at:
https://medium.com/karuna-sehgal/a-simplified-explanation-of-the-big-o-notation-
82523585e835
Accessed by (2022/01/23)

Available at:
https://towardsdatascience.com/demystifying-binary-search-bed0274e27e7
Accessed by (2022/01/23)

M.A.M.AFRI 85
Available at:
https://searchsoftwarequality.techtarget.com/definition/integrated-developmentenvironment
Accessed by (2022/01/23)

M.A.M.AFRI 86
Acknowledgment
In preparation of my assignment, I had to take the help and guidance of some respected
persons, who deserve my deepest gratitude. As the completion of this assignment gave me
much pleasure, I would like to show my gratitude Mr.Safran, Course Instructor. Whatever I
have done is only due to such guidance and assistance and I would not forget to thank him. I
respect and thank all my colleagues at the ESOFT METRO CAMPUS, for providing me all
support and guidance, which made me complete the assignment on time. I am extremely
grateful to be a part of this amazing team. Thanking you.

M.A.M.AFRI

M.A.M.AFRI 87
M.A.M.AFRI 88
M.A.M.AFRI 89

You might also like