Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
Programme title
Assessor
Internal Verifier
Unit(s)
Assignment title
Student’s name
List which assessment criteria
the Assessor has awarded.
Pass
Merit
Distinction
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 comments on the
student work?
Has the work been assessed
accurately?
Is the feedback to the student:
Give details:
• Constructive?
• Linked to relevant assessment criteria?
• Identifying opportunities for
improved performance?
• Agreeing actions?
Does the assessment decision need
amending?
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Assessor signature
Date
Internal Verifier signature
Date
Programme Leader signature (if required)
Date
[COL/E-007252]
1
Confirm action completed
Remedial action taken
Give details:
Assessor signature
Date
Internal Verifier
signature
Date
Programme Leader
signature (if required)
Date
[COL/E-007252]
2
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID
Muthiah Udayawarman
Unit Title
Programming
Assignment Number
Assessor
Submission Date
Date Received 1st
submission
Re-submission Date
Date Received 2nd
submission
Assessor Feedback:
LO1. Define basic algorithms to carry out an operation and outline the process of programming an application.
Pass, Merit & Distinction Descripts
P1
M1
D1
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a suita
Integrated Development Environment (IDE).
Pass, Merit & Distinction Descripts
P2
M2
D2
M3
D3
LO3. Implement basic algorithms in code using an IDE.
Pass, Merit & Distinction Descripts
P3
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts
Grade:
P4
P5
M4
Assessor Signature:
Date:
Assessor Signature:
Date:
D4
Resubmission Feedback:
Grade:
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.
[COL/E-007252]
3
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Feedback: Student to Assessor
Assessor
signature
Date
Student
signature
Date
[COL/E-007252]
4
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
[COL/E-007252]
5
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.
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. Don’t 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.
[COL/E-007252]
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:
(Provide E-mail ID)
[COL/E-007252]
Date:
(Provide Submission Date)
7
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number
Unit Number and Title
Unit 01: Programming
Academic Year
2017/18
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 ability to modify
and debug the system using the IDE.
[COL/E-007252]
8
This submission will have 3 components
4. 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)
5. 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.
6. 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 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
[COL/E-007252]
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 is meant by a Programming Paradigm. 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.
Activity 3 and Activity 4 are based on the following Scenario.
[COL/E-007252]
10
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 2 or more days.
Activity 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 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.
[COL/E-007252]
11
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
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
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.
[COL/E-007252]
12
[COL/E-007252]
13
rading 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
[COL/E-007252]
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.
P3 Write a program that implements an algorithm using an
IDE.
[COL/E-007252]
15
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.
D4 Critically evaluate why a coding standard is necessary in
a team as well as for the individual.
[COL/E-007252]
16
Learn Coding
Love Coding
Live Coding
2019
PROGRAMMING
Muthiah Udayawarman
[COL/E-007252]
Batch 85
17
Table of Contents
List of Figures .......................................................................................................................... 19
Acknowledgement ................................................................................................................... 20
Activity 1.................................................................................................................................. 21
Activity 1.1........................................................................................................................... 21
Activity 1.2........................................................................................................................... 26
Activity 1.3........................................................................................................................... 31
Activity 2.................................................................................................................................. 33
Activity 2.1........................................................................................................................... 33
Activity 2.2........................................................................................................................... 35
Activity 2.3........................................................................................................................... 37
Activity 3.................................................................................................................................. 41
[COL/E-007252]
18
List of Figures
Figure 1 Linear Search
Figure 2 Linear search array and index
Figure 3 a Binary search
Figure 4 welcome form
Figure 5 Rent Calculation form
Figure 6 button code
Figure 7 Operation class code 1
Figure 8 Operation class code 2
Figure 9 Day calculation Hiring
Figure 10 Hire calculation button code 1
Figure 11 Hire calculation button code 2
Figure 12 operation code 1
Figure 13 operation code 2
Figure 14 operation code 3
Figure 15 2nd operation code
Figure 16 3rd Operation code
Figure 17 4th operation code
[COL/E-007252]
22
22
24
41
41
42
42
43
43
44
44
44
45
45
45
46
46
19
Acknowledgement
In preparation of my assignment, I had to take the help and guidance of some respected
persons who deserve my Higher National Diploma as the completion of this assignment gave
me much pleasure, I would like to show my higher national diploma to Mr. Tharaka Sir,
Course lecture on Esoft Metro Campus for giving me a good guideline for assignment
throughout numerous consolations. I would also like to expand my diploma to all those who
have directly guided me in doing this assignment.
In addition, a thank you to my batch brothers and friends who
helped to do this assignment in good pathway and had lasting effect. many people, especially
my classmate have made valuable comment suggestions on my paper which gave me an
inspiration to improve the quality of the assignment.
The success and final outcome of this project required
a lot of guidance and assistance from many people and I am extremely privileged to have got
this all along the completion of my project. All that I have done is only due to such supervision
and assistance and I would not forget to thank them..
[COL/E-007252]
20
Activity 1
Activity 1.1
What is algorithm
An algorithm is a step by step technique of solving a problem. It is normally used for
processing, calculation and other connected pc and mathematical operations. An algorithm is
also accustomed manipulate data in numerous ways in which, like inserting a brand new
information item, sorting out a specific item or sorting an item.
An algorithmic rule is a elaborate series of directions
for polishing off an operation or finding a problem. In a non-technical approach, we have a
tendency to use algorithms in everyday tasks, like a instruction to bake a cake or a homemade
reference book. Technically, computers use algorithms to list the detailed directions for
finishing up AN operation. For example, to work out an employee’s bank check, the pc uses
an algorithmic rule. To accomplish this task, applicable information should be entered into
the system. In terms of potency, numerous algorithms area unit able to accomplish operations
or drawback finding simply and quickly.
The characteristics of a good algorithm are:






Precision – The steps are precisely stated.
Uniqueness – Results of each step are uniquely defined and only depend on the input
and the result of the preceding steps.
Finiteness – The algorithm stops after a finite number of instructions are executed.
Input – The algorithm receives input.
Output – The algorithm produces output.
Generality – The algorithm applies to a set of inputs.
[COL/E-007252]
21
Linear Search
Figure 1 Linear Search



Start from the leftmost element of arr[] and one by one compare x with each element of
arr[]
If x matches with an element, return the index.
If x doesn’t match with any of elements, return -1.
In computing, a linear search or successive search may be
a technique for locating an element inside a list. It consecutive checks every part of the
list till a match is found or the entire list has been searched. A linear search runs in at
worst linear time and makes at most n comparisons, where n is the length of the list.
If every part is equally doubtless to be searched, then linear search has an average case
of (n/2). comparisons, however the common case is affected if the search chances for
every element vary. Linear search is rarely practical because other search algorithms and
schemes, such as the binary search algorithm and hash tables, allow significantly faster
searching for all but short lists.
Figure 2 Linear search array and index
[COL/E-007252]
22
Pseudo Code
Pseudocode is a casual manner of programming description that doesn't need any strict
programing language syntax or underlying technology issues. It is used for making an overview
or a rough draft of a program. Pseudocode summarizes a program’s flow, however excludes
underlying details. System designers write pseudocode to make sure that programmers perceive
a computer code project's needs and align code consequently.
Pseudo Code For Linear Search
Pseudocode: FUNCTION linearSearch(list, SearchTerm):
FOR index FROM 0 -> length(list):
IF list[index] == SearchTerm THEN
RETURN index
ENDIF
ENDLOOP
RETURN -1
ENDFUNCTION
[COL/E-007252]
23
Binary Search
Search a sorted array by frequently dividing the search interval in half. Begin with an interval
covering the whole array. If the element of the search key's but the item within the middle of
the interval, slender the interval to the lower half. Otherwise narrow it to the upper half. again
check till the element is locate or the interval is empty.
Figure 3 a Binary search




Compare x with the middle element.
If x matches with middle element, we return the mid index.
Else If x is greater than the mid element, then x can only lie in right half subarray
after the mid element. So we recur for right half.
Else (x is smaller) recur for the left half.
Pseudo Code for Binary Search
Procedure binary_search
A ← sorted array
n ← size of array
x ← value to be searched
Set lowerBound = 1
Set upperBound = n
while x not found
if upperBound < lowerBound
EXIT: x does not exists.
set midPoint = lowerBound + (upperBound - lowerBound) / 2
if A[midPoint] < x
set lowerBound = midPoint + 1
[COL/E-007252]
24
if A[midPoint] > x
set upperBound = midPoint - 1
if A[midPoint] = x
EXIT: x found at location midPoint
end while
end procedure
[COL/E-007252]
25
Activity 1.2
The Programming Process
Developing a program involves steps just like any problem solving task. There are main five
steps within the programming process:





Defining the problem
Design the program
Code the program
Testing the program
Document and Maintain
Defining the problem
Knowing the objective is the first consideration. Is it a payroll or editing program? Knowing
who the top user are is additionally necessary. Determining the inputs and outputs is next. How
can the program operate and what knowledge is required to form it happen? After this has been
set practicability is that the next thought. How many programmers can it take, is that the project
at intervals budget, will the project have a sensible define. Finally, if the project is a go, then
one should take measures to make sure the project is correctly documented and analyzed.
Design the Program
Programs use algorithms that are like equations that tell the pc what task to perform. The aim
of the coder is to make algorithms that are clear and easy. Algorithms are expressed first in
logical hierarchical form known as modularization. Using modules or (a complete thought) the
coder creates a logical thought method for the pc to follow. After that the program is attenuated
in greater detail exploitation pseudocode. Pseudocode uses terms like if, else, and, then to relate
the programs rules to the pc.
Code the program
After the program has been designed it should be coded or written. Using the pseudocode
associate degreed logic needs from step two an appropriate programing language should be
selected. As expressed within the introduction, writing languages disagree in specifications and
usefulness. Once the suitable code language has been chosen, it's imperative that the coder
follow the syntax rules with as very little deviation as potential so as for the program to have
high accuracy.
[COL/E-007252]
26
Testing the program
After the program is written it then enters the programming debugging and testing part of the
Program Development Life Cycle. During this point the coder are going to be trying to find
errors in each logic and syntax, yet as exploring different areas that will cause the program to
either not work properly or to not run at all. This process is a lengthy and tedious one,
oftentimes consisting of up to 50% of a program’s time in development. However, with a
careful eye paid to program style and coding the quantity of your time spent debugging can be
cut significantly. As stated, debugging can uncover errors in each logic and syntax.
Syntax errors will prevent the program from executing. They will be such easy things as
misspelled words or can involve breaking the syntax rules of the programming language used.
On the opposite hand, logic errors can enable the program to run however can offer incorrect
results. Errors of this type could include simply mistreatment the incorrect relative operator or
larger, mistakes in writing formulas. Once the coder locates the errors they're then fastened and
therefore the program is run once more. This will happen multiple times, usually known as
“execute, check, and correct”, till the program runs cleanly. The program will then enter the
testing phase
Document and Maintain
Documentation should be current from the terribly starting as a result of it's required for those
committed program currently and future. Upon completion User Documentation for industrial
use, Operator Documentation for those that run computer systems, and coder Documentation
for programmers charged with maintenance. Every program desires positive amount and
memory to process the instructions and data. As the process power and memory area unit the
foremost precious resources of a pc, a program ought to be ordered go into such a fashion that
it utilizes the smallest amount of memory and processing time.
[COL/E-007252]
27
Run The Binary Search
For a binary search to figure, it's necessary for the target array to be sorted. We shall learn the
method of binary search with a pictorial example. The following is our sorted array and allow
us to assume that we want to look the situation valuable 31 exploitation binary search.
Here it is, 0 + (9 - 0) / 2 = 4 (integer value of 4.5). So, 4 is the mid of the array.
Now we compare the value stored at location 4, with the value being searched, i.e. 31. We
find that the value at location 4 is 27, which is not a match. As the value is greater than 27
and we have a sorted array, so we also know that the target value must be in the upper portion
of the array.
We
change our low to mid + 1 and find the new mid value again.
Low = mid + 1
Mid = Low + (High – Low)/2
Our new mid is 7 now. We compare the value stored at location 7 with our target value 31.
[COL/E-007252]
28
The value stored at location 7 is not a match, rather it is more than what we are looking for.
So, the value must be in the lower part from this location.
Hence, we calculate the mid again. This time it is 5.
We compare the value stored at location 5 with our target value. We find that it is a match.
We conclude that the target value 31 is stored at location 5.
Binary search halves the searchable items and thus reduces the count of comparisons to be
made to very less numbers.
[COL/E-007252]
29
Run The Linear Search
ar[0]
ar[1]
ar[2]
ar[3]
ar[4] ar[5]
ar[6
ar[7]
ar[8]
Element to Search – 5
1. Start from the leftmost element of array and one by one compare the element we are
searching for with each element of the array.
2. If there is a match between the element we are searching for and an element of the
array, return the index.
3. If there is no match between the element we are searching for and an element of the
array, return -1.

Comparison between Binary Search and Linear Search:
Binary Search needs the input data to be sorted; Linear Search doesn’t

Binary Search needs an ordering comparison; Linear Search only needs equality
comparisons

Binary Search has complexness O(log n); Linear search has complexity O(n) as
mentioned earlier

Binary Search needs random access to the data; Linear Search solely needs sequent
access (this can be important — it means that a Linear Search will stream data of
impulsive size)
[COL/E-007252]
30
Activity 1.3
What is Big O notation
Big O notation is a explicit tool for assessing algorithmic program potency. Big O notation is
usually wont to show however programs want resources relative to their input size.
Essentially, victimization big O notation helps to calculate desires as a program scales. The
size of a program's input is given to the computer, and then the running time and space
requirements are determined. Engineers will get a visible graph that shows desires relative to
completely different input sizes. Big O notation is additionally employed in different kinds of
measurements in different fields. It is an example of a basic equation with a lot of parameters
and variables.
Python Program for Linear search
def search(arr, n, x):
for i in range (0, n):
if (arr[i] == x):
return i;
return -1;
# Driver Code
arr = [ 2, 3, 4, 10, 40 ];
x = 10;
n = len(arr);
result = search(arr, n, x)
if(result == -1):
print( "Element is not present in array" )
else:
print(" Element is present at index ", result );
[COL/E-007252]
31
Python Program for Binary search
# Returns index of x in arr if present, else -1
def binarySearch (arr, l, r, x):
# Check base case
if r >= l:
mid = l + (r - l)/2
# If element is present at the middle itself
if arr[mid] == x:
return mid
# If element is smaller than mid, then it can only
# be present in left subarray
elif arr[mid] > x:
return binarySearch(arr, l, mid-1, x)
# Else the element can only be present in right subarray
else:
return binarySearch(arr, mid+1, r, x)
else:
# Element is not present in the array
return -1
[COL/E-007252]
32
Activity 2
Activity 2.1
Programming Paradigm
What is Programming Paradigm
A Programming Paradigm is a style, or “way,” of programming.
Object Oriented Program
Object Oriented Program is predicated on the sending of messages to things. Objects reply to
messages by performing arts operations, typically referred to as ways. Messages can have
arguments. A society of objects, every with their own native memory and own set of operations
has a completely different feel than the monolithic processor and single shared memory feel of
non object oriented languages. One of the more visible aspects of the purer is Object Oriented
languages is that conditionals and loops become messages themselves, whose arguments are
often blocks of executable code. In a Smalltalk like syntax.
Event Driven Program
Event-driven programming is a programming paradigm within which the flow of program
execution is set by events - for instance a user action like a depression, key press, or a message
from the operating system or another program. An event-driven application is intended to
notice events as they occur, then wear down them exploitation an acceptable event-handling
procedure. The idea is an extension of interrupt-driven programming of the kind found in early
command-line environments such as DOS, and in embedded systems (where the application is
implemented as firmware).
Relationship between Object Oriented Programming and Event Driven
Object oriented and event driven programming are each vital programming techniques that are
used in our nowadays of software development. In the method of learning a way to program
with varied programming languages, it's necessary for you to be able to recognize what
specifically is that the distinction between object oriented and event driven programming
techniques. Object destined programming is a programing language model that's organized
around objects instead of actions (which are employed in event driven programming) and
information instead of logic.
On the opposite hand, event driven programming may be a programming paradigm within
which the flow of the program is decided by events like user actions (mouse clicks, key
presses), sensor outputs, or messages from other programs or threads Procedural, event-driven
and object-oriented paradigms are used to classify programming languages. A procedural
programming paradigm is represented as a series of steps in which a computer programmer
writes a code to perform a specific task. The first line of code is executed first, then the second
line of code, then the third, up to last line of code. Therefore, procedural programming is a topdown approach to executing lines of codes. The most popular languages that use procedural
paradigm are BASIC, COBOL, PASCAL and FORTRAN. In these languages, a program
comprises of steps or procedures that operate on data. Procedural programming has many
characteristics like local variables, global variables, pre-defined functions, modularity, and
parameter passing in function and procedures.
[COL/E-007252]
33
While the procedural paradigm uses steps, the event-driven paradigm approach uses events
from the user to execute functions on the data. These events could be a simple mouse click or
a combination of key-presses from the user (like in GUI based programs) or could also be a
message from other programs. Programming languages constantly listen or sense for an event,
which then calls the respective function when the event is detected. Since most of the GUI
applications depend on user actions, these GUI programming languages will have an eventdriven paradigm based programming as an essential part. The characteristics of event-driven
programming are that these are service oriented, use event handlers and triggers, have userinterfaces and are time driven. Most popular languages specially for GUI or visual applications
that use event-driven paradigm are visual C++, Java, Visual Basic.
The object-oriented paradigm is different from both the steps based paradigm of procedural
and the trigger/event based paradigm of event-driven, in the sense that the object-oriented
paradigm is based on objects and classes and their re-use to perform a specific code-function.
So, unlike the procedural paradigm, the object-oriented paradigm uses bottom-up approach. In
the simplest form, these objects contain data in the form of fields. Programs are divided into
smaller units known as objects belonging to a class. These objects interact with each other
through functions. Most popular languages that use object-oriented paradigm are C++, Java,
Objective C, Python. The characteristics of languages using the object-oriented paradigms are
the use of objects, classes, encapsulation, inheritance, data abstraction, dynamic binding,
message passing and polymorphism.
[COL/E-007252]
34
Activity 2.2
Object Oriented Example
class Parrot:
# class attribute
species = "bird"
# instance attribute
def __init__(self, name, age):
self.name = name
self.age = age
# instantiate the Parrot class
blu = Parrot("Blu", 10)
woo = Parrot("Woo", 15)
# access the class attributes
print("Blu is a {}".format(blu.__class__.species))
print("Woo is also a {}".format(woo.__class__.species))
# access the instance attributes
print("{} is {} years old".format( blu.name, blu.age))
print("{} is {} years old".format( woo.name, woo.age))
[COL/E-007252]
35
Event Driven Example
import turtle
turtle.setup(400,500)
wn = turtle.Screen()
wn.title("Handling keypresses!")
wn.bgcolor("lightgreen")
tess = turtle.Turtle()
# The next four functions are our "event handlers".
def h1():
tess.forward(30)
def h2():
tess.left(45)
def h3():
tess.right(45)
def h4():
wn.bye()
# These lines "wire up" keypresses to the handlers we've defined.
wn.onkey(h1, "Up")
wn.onkey(h2, "Left")
wn.onkey(h3, "Right")
wn.onkey(h4, "q")
# Now we need to tell the window to start listening for events,
# If any of the keys that we're monitoring is pressed, its
# handler will be called.
wn.listen()
wn.mainloop()
[COL/E-007252]
36
Event Driven Example
new_lst = [1, 2, 3, 4]
def sum_list(lst):
result = 0
for value in lst:
result += value
return result
print(sum_list(new_lst))
Activity 2.3
Structure and The Unique Characteristics
Unlike with the object-oriented programming, that is data and model targeted, procedural
programming concentrate on sequences of actions to be done. From the purpose of
programming, knowledge is that the reason for the existence of a program. In procedural
languages like C, programs square measure composed of procedures or functions and every
procedure is a sequence of statements that contains a specific outlined purpose.
The Characteristics of Procedural Programming
Focus on process or doing things rather than data. The whole program is implemented
based on actions such as reading, calculating and printing. Therefore, a bunch of functions
is written to solve a program from top to down. Global data is often shared by all functions.
Data moves openly from function to function.
The Disadvantages of Procedural Programming
Bad code-ruse. Not like category and objects that check the real-world model, functions in PP
are task oriented and cannot be reused once meeting a unique one. Except for some commonly
used library functions, we need to write many repetitive codes for similar problems.
Hard to expand the application. The entire process in PP is coded directly into the application,
very-task related. For example, an application in PP for registering the user will not be used for
logging on and off. Difficult to create new data types. Hard to maintain. It will be a temporal
arrangement consuming answer to create changes. If one perform accidentally changes price
of the worldwide data, all the functions who access to the present world data should
modification their values. No information hiding. Data is exposed to the complete program, so
no security for data. Hard to design. For example, in designing graphical user interface, we'd
better mainly concentrate on how to design a menu, a button etc. Since individuals can see
them initially sight, not actions behind.
[COL/E-007252]
37
The Advantages of Procedural Programming
Simple. No ought to consider code reusing for later use, simply consider a way to end this
task. Ease of implantation of compilers and interpreters. Easy to stay track of workflow.
Needs less memory. There’s no information abstraction resulting in an outsized code size
that consumes variant memory. A quite standard programming that helps to learn OOP
later.
Object-Oriented Programming (OOP) is a programming paradigm where different
components of a computer program are modeled after real-world objects. An object is
something that has some characteristics and can perform a operate. Consider a scenario
where you have to develop a Formula 1 car racing game using the object-oriented
programming approach. The first thing you need to do is to identify real-world objects
in the actual Formula 1 race. What area unit the entities in an exceedingly Formula one
race that have some characteristics and may perform any function? One of the obvious
answers to this question is the car. A automobile will have characteristics like engine
capacity, make, model, manufacturer, and so on. Similarly, a car can be started, stopped,
accelerated and so on. A driver can be another object in a Formula 1 race. A driver has
a nationality, age, gender, and so on, and he can perform functionalities like driving the
car, moving the steering or changing the transmission.
Just like in this example, in object-oriented programming we will create objects for the
corresponding real-world entity. It is important to mention here that object-oriented
programming is not a language-dependent concept. It is a general programming concept
and most of the modern languages, such as Java, C#, C++, and Python, support objectoriented programming. In this article, we will see a detailed introduction to ObjectOriented Programming in Python, but before that, we will see some of the advantages
and disadvantages of object-oriented programming. Event-driven programming called a
programming paradigm that used the incidence of events to see the management flow of
the program.
This type of application is meant to find events as they occur Associate in Nursing use
an acceptable event-handling procedure to influence it, which normally use a callback
function or method. Theoretically, event-driven style of programming is supported in all
programming languages, but they may different in the way of implement it, for example,
it’s easier to implement in languages that provide high-level abstractions, such as
closures. Besides, for different programming environments like Adobe Flash, they are
specifically tailored for triggering program code by events. Generally, there's a main
loop in an event-driven application that wont to listen for events and triggers a recall
operate once there area unit events is detected. Key features and characteristics of event
driven programming Service Oriented Service headed could be a key options in eventdriven programming that wont to write programs that area unit created for services and
it takes doesn't cut down the pc as service oriented solely consume very little of the pc
process power and typically services run within the background of OS.
[COL/E-007252]
38
Time Driven
In event driven programming, time driven may be a paradigm, it’s a code that runs on a
time trigger, time driven may be a particular code that runs on a particular time, which
could be once an hour, once a week or once a month, this means it’s a pre-set to do task.
For example, windows update is the example of time driven, which user can set when to
update or when to check and download the update.
Event Handlers
Event handlers may be a kind of operate or methodology that run a particular action once
a particular event is triggered. For example, it could be a button that when user click it, it
will display a message, and it will close the message when user click the button again,
this is an event handler.
Trigger Functions
Trigger functions in event-driven programming are a functions that decide what code to
run when there are a specific event occurs, which are used to select which event handler
to use for the event once there's specific event occurred.
Events
Events embody mouse, keyboard and programmer, which events need to be triggered in
the program in order to happen, that mean user have to interacts with an object in the
program, for example, click a button by a mouse, use keyboard to select a button and etc.
Simplicity of Programming and Ease of Development
Event-driven programming is easy and easier to program compared to different kind of
programming as it’s terribly visual, for instance you'll be able to place a button by simply
choose it and place it onto a kind and write a code for it.Event driven programming
additionally straightforward for user to insert a pre-written code scripts into associate
degree existing application as a result of it permits user to pause the code whereas it’s
running. Which make developing using event-driven programming is easy.
Compare Event Driven Programming with Object-oriented Programming
As mentioned on top of, event-driven programming known as a computer programming
paradigm that used the occurrence of events to determine the control flow of the program,
while objects-oriented programming (OOP) treats data fields as objects manipulated
through pre-defined methods only and it constructed over four major principles, which are
Encapsulation,
Data
Abstraction,
Polymorphism
and
Inheritance.
JavaScript, ActionScript, Visual Basic and Elm are the example for event-driven
programming, while C++, C#, Java, Python, Ruby and Scala are the examples for object oriented programming.
[COL/E-007252]
39
In event-driven programming, a program is executed when they detected an event occur,
for example, use mouse to click a button to show a message. Besides, in object-oriented
programming, emphasis is given to data and classes are the main part of OOP, which mean
classes are the blueprints of object and keep the data secure within the categories, only
methods of particular classes are allowed to view the data.
The categories also are very different between event-driven programming and object
homeward-bound programming. In OOP, categories may be created by own whereas
in event-driven programming user should use the outlined categories. Object-oriented
programming and event-driven programming may use together, which mentioned
above that event-driven programming are support in all programming language, it’s
just the way of implement it may different.
[COL/E-007252]
40
Activity 3
Ayubo Leisure Welcome Form
Figure 4 welcome form
Rent Calculation Form
Figure 5 Rent Calculation form
[COL/E-007252]
41
Calculate Button Code
Figure 6 button code
Operation Class For Calculation
Figure 7 Operation class code 1
[COL/E-007252]
42
Figure 8 Operation class code 2
Hire Calculation Form
Figure 9 Day calculation Hiring
[COL/E-007252]
43
Calculate Button code
Figure 10 Hire calculation button code 1
Figure 11 Hire calculation button code 2
Operation class code
Figure 12 operation code 1
[COL/E-007252]
44
Figure 13 operation code 2
Figure 14 operation code 3
2nd Operation code
Figure 15 2nd operation code
[COL/E-007252]
45
3rd Operation code
Figure 16 3rd Operation code
4th operation code
Figure 17 4th operation code
[COL/E-007252]
46
Activity 4
Ayubo Leisure Data Tables
Figure 18 Car Table
Figure 19 Package Table
Integrated Development Environment(IDE)
An integrated development environment (IDE) could be a software package application that
gives comprehensive facilities to pc programmers for software package development. An IDE
usually consists of a minimum of a source code editor, build automation tools, and a computer
program. Some IDEs, such as NetBeans and Eclipse, contain the necessary compiler,
interpreter, or both; others, such as Sharp Develop and Lazarus, do not. The boundary between
an IDE and other parts of the broader software development environment is not well defined;
sometimes a version control system or various tools to simplify the construction of a graphical
user interface (GUI) are integrated. Many trendy day even have a category browser, associate
object browser, and a category hierarchy diagram to be used in object-oriented software
package development.
Benefits Of Visual Studio IDE
 Syntax highlighting
 Code Completion
 Refactoring
 Version Control
 Debugging
 Code Search
 Visual Programming
 Language Support
 Attitudes across different computing platforms
[COL/E-007252]
47
Syntax Highlighting
The Integrated Development Environment (IDE) editor typically provides syntax highlight, it
will show each the structures, the language keywords and also the syntax errors with visually
distinct colors and font effects.
Code Completion
Code completion is an important IDE feature, meant to speed up programming, and modern
IDEs even have intelligent code completion.
Refactoring
Advanced IDEs provide support for automated refactoring.
Version control
An IDE is expected to provide integrated version control, in order to interact with source
repositories.
Debugging
IDEs are also used for debugging, using an integrated debugger, with support for setting
breakpoints in the editor, visual rendering of steps, etc.
Code search
IDEs may provide advanced support for code search: in order to find class and function
declarations, usages, variable and field read/write, etc. IDEs can use different kinds of user
interface for code search, for example form-based widgets and natural-language based
interfaces.
Visual programming
Visual programming may be a usage scenario during which associate IDE is usually needed.
Visual Basic permits users to form new applications by moving programming, building blocks,
or code nodes to form flowcharts or structure diagrams that square measure then compiled or
taken. These flowcharts typically square measure supported the Unified Modeling Language.
This interface has been popularized with the Lego Mind storms system, and is being actively
pursued by variety of firms desire to make the most the facility of custom browsers like those
found at Mozilla. KTechlab supports flow code and may be a fashionable open source IDE and
machine for developing package for microcontrollers. Visual programming is additionally to
blame for the facility of distributed programming (cf.LabVIEW and EICASLAB software). An
early visual programming system, Max, was sculptural when analog synthesizer style and has
been wont to develop time period music performance package since the Nineteen Eighties.
Another early example was Paragraph, a dataflow-based system originally developed for the
Macintosh. The graphical programming surroundings "Grape" is employed to program qfix
mechanism kits. This approach is additionally employed in specialist package like Open lab,
wherever the tip users wish the flexibleness of a full artificial language, while not the normal
learning curve related to one.
[COL/E-007252]
48
Language Support
Some day support multiple languages, like antelope Emacs supported C and Emacs Lisp, and
IntelliJ plan, Eclipse, MyEclipse or NetBeans, all supported Java, or MonoDevelop, based on
C#, or PlayCode. Support for different languages is commonly provided by plugins,
permitting them to be put in on an equivalent IDE at an equivalent time. For example,
Flycheck may be a trendy on-the-fly syntax checking extension for antelope Emacs twenty
four with support for thirty-nine languages. Eclipse, and Netbeans have plugins for C/C++,
Ada, GNAT (for example AdaGIDE), Perl, Python, Ruby, and PHP, that are elect between
mechanically supported file extension, setting or project settings.
Attitudes across different computing platforms
Unix programmers will mix command-line POSIX tools into a whole development setting,
capable of developing massive programs like the UNIX operating system kernel and its
setting. During this sense, the entire Unix system functions as an IDE.[9] The free software
GNU tools (GNU Compiler Collection (GCC), GNU Debugger , and GNU make) are
available on many platforms, including Windows.[10] The pervasive Unix philosophy of
"everything may be a text stream" permits developers United Nations agency favor commandline adjusted tools to use editors with support for several of the quality OS and wildebeest
build tools, building Associate in Nursing IDE with programs like Emacs[11][12][13] or Vim.
Data show computer program is meant to be a sophisticated graphical front-end for several
text-based computer program normal tools. Some programmers prefer managing make files
and their derivatives to the similar code building tools included in a full IDE. For example,
most contributors to the PostgreSQL database use make and gdb directly to develop new
features. Even when building PostgreSQL for Microsoft Windows using Visual C++, Perl
scripts are used as a replacement for create instead of hoping on any IDE options. Some Linux
IDEs such as Geary attempt to provide a graphical front end to traditional build On the varied
Microsoft Windows platforms, command-line tools for development are seldom used.
Accordingly, there are many commercial and non-commercial products.
However, every incorporates a completely different style usually making incompatibilities.
Most major compiler vendors for Windows still offer free copies of their command-line tools,
including Microsoft (Visual C++, Platform SDK, .NET Framework SDK, make utility).
IDEs have always been popular on the Apple Macintosh's classic Mac OS and macOS, dating
back to Macintosh Programmer's Workshop, Turbo Pascal, THINK Pascal and THINK C
environments of the mid-1980s. Currently macOS programmers will choose from native day
like Xcode and ASCII text file tools like Eclipse and Netbeans. Active State Komodo may be
a proprietary Multilanguage IDE supported on macOS.
[COL/E-007252]
49
Figure 20 Calculation And Record
Figure 21 GUI form Manage Cars
[COL/E-007252]
50
Code for Insert
Figure 22 insert code 1
Figure 23 insert code 2
[COL/E-007252]
51
What is Debugging an Application
Developing package programs endure significant testing, updating, troubleshooting and
maintenance. Normally, package contains errors and bugs, that area unit habitually removed.
In the debugging method, complete package programs area unit often compiled and dead to
spot and rectify problems. Large package programs, that contain several source code lines, area
unit divided into little elements. For potency, every part is debugged one by one initially,
followed by the program as an entire. This system is easy to reach and helps the students to
achieve easy education during this period.I give thanks to those who have helped me to achieve
this easy education. This easy way can be used to make a good position in education
[COL/E-007252]
52