0% found this document useful (0 votes)
116 views37 pages

Informatics College Pokhara: Fundamentals of Computing CS4051NP

This document describes a coursework project to develop a software application for integer addition using a digital circuit model. It includes: 1. Developing models of half adders and full adders using logic gates like XOR and OR to perform bitwise operations. Truth tables are used to derive the outputs. 2. Creating a flowchart and pseudocode to design the algorithm for integer addition based on bit operations. 3. Implementing the adder model in a Python program that takes two integers as input, converts them to binary lists, performs bitwise addition in a loop, and outputs the sum in binary or decimal format. 4. Testing the program by providing different input combinations and verifying the output

Uploaded by

Avash Joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
116 views37 pages

Informatics College Pokhara: Fundamentals of Computing CS4051NP

This document describes a coursework project to develop a software application for integer addition using a digital circuit model. It includes: 1. Developing models of half adders and full adders using logic gates like XOR and OR to perform bitwise operations. Truth tables are used to derive the outputs. 2. Creating a flowchart and pseudocode to design the algorithm for integer addition based on bit operations. 3. Implementing the adder model in a Python program that takes two integers as input, converts them to binary lists, performs bitwise addition in a loop, and outputs the sum in binary or decimal format. 4. Testing the program by providing different input combinations and verifying the output

Uploaded by

Avash Joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 37

Informatics College Pokhara

Fundamentals of Computing
CS4051NP

Coursework I

Submitted By: Submitted To:


Name: Avash Joshi Mr. Sandeep Gurung
London Met ID: 19030801 Model Leader
Group: C1 Fundamentals of Computing
Date: 8 June 2020
TABLE OF CONTENTS

1. Introduction ............................................................................................................................... 1

2. Model ......................................................................................................................................... 3

2.1 Half Adder .......................................................................................................................... 4

2.2 Full Adder ........................................................................................................................... 7

2.3 Logic Gates ....................................................................................................................... 12

3. Algorithm ................................................................................................................................. 14

4. Flow Chart ............................................................................................................................... 15

5. Pseudocode .............................................................................................................................. 17

6. Data Structure .......................................................................................................................... 23

7. Testing...................................................................................................................................... 24

7.1. Test I.................................................................................................................................. 24

7.2. Test II ................................................................................................................................ 25

7.3. Test III ............................................................................................................................... 26

7.4. Test IV............................................................................................................................... 27

7.5. Test V ................................................................................................................................ 28

7.6. Test VI............................................................................................................................... 29

8. Conclusion ............................................................................................................................... 31

9. References................................................................................................................................ 32
TABLE OF FIGURES

Figure 1: Bit Adder Circuit Model ................................................................................................... 3


Figure 2: Single Bit Half Adder........................................................................................................ 4
Figure 3: Half Adder Circuit ............................................................................................................. 5
Figure 4: Single Bit Full Adder ........................................................................................................ 7
Figure 5: Multi-Bit Addition using Full Adder ............................................................................... 8
Figure 6: Parallel 8-bit Adder Circuit............................................................................................... 8
Figure 7: Full Adder Circuit ........................................................................................................... 10
Figure 8: Full Adder using Half Adders ........................................................................................ 10
Figure 9: Full Adder using NAND gates ....................................................................................... 11
Figure 10: Full Adder using NOR gates ........................................................................................ 11
Figure 11: Flowchart ....................................................................................................................... 16
Figure 12: Test I............................................................................................................................... 24
Figure 13: Test II ............................................................................................................................. 25
Figure 14: Test III ............................................................................................................................ 26
Figure 15: Test IV............................................................................................................................ 27
Figure 16: Test V ............................................................................................................................. 28
Figure 17: Test VI............................................................................................................................ 29
TABLE OF TABLES

Table 1: Truth Table of Half Adder ................................................................................................. 6


Table 2: Truth Table of Full Adder .................................................................................................. 9
Table 3: Test I .................................................................................................................................. 25
Table 4: Test II ................................................................................................................................. 26
Table 5: Test III ............................................................................................................................... 26
Table 6: Test IV ............................................................................................................................... 27
Table 7: Test V ................................................................................................................................ 28
Table 8: Test VI ............................................................................................................................... 30
CS4051NP Fundamentals of Computing

1. INTRODUCTION
Python is a general-purpose, interpreted high-level programming language that allows programmers to
use various programming outlets to create easy or difficult programs, get quicker outputs and is designed
to read at ease and simple to implement (Janssen, 2019). One can use Python for developing complex
scientific and numeric applications. Similarly, as we were learning the methodology of Python, an
individual coursework for this module was delivered to students that demands organizing a software
application for a digital circuit to calculate integer addition. This report of mine provides all the important
mechanisms of the model, algorithm, data structures, program and testing as well.

It is all necessity to build programs in Python that carry out the system of data and inferences of the
adder we developed, then test the program accordingly. Besides, the project integrates the manufacture
of a model of a byte adder forgathered with the help of electronic gates such as XOR Gate, OR Gate &
AND Gate, predicated through bit adder by prescribing an algorithm for addition of integer based on
bitwise operations, after that, choosing favorable python data structures to categorize the data or findings
that is to be processed by the program. And before the software application was developed with the
model, I drew flowchart diagram and then wrote algorithm in a stepwise manner specified with
pseudocode in order to make coding better understandable and work effective. After that, I created a
program implementing the model of the binary adder constructed in the beginning. The program
performs an operation in a circular strip that is loop, scanning user provided two integer digits computing
the total sum of the numbers then prints the result according to the instructions in binary or decimal.

I ensured a full adder to give practical effect using one OR gate and two half adders since its simple to
carry out half adder. In full adder and half adder, I have applied K-Map simplification to prevail the
mathematical expression for the output of Sum and Carry. The only data structure that has been used in
the program is ‘List’ for instance; conversion of integer number to binary list. The program that I have
formed is constructed with standardized units in a modular way with individual functions for inputting
data, integer operations, bit operations, and following the output result of the whole mathematical
operations to find a value. The adder model is well explained through better illustrations. To add, I have
used draw.io and lucid chart for the construction of circuit diagrams.

The flexibility of this individual coursework of Fundamentals of Computing leads to develop our skills
and knowledge even more on python and mostly the function of byte adder. It is important to meet all
the required aspects as mentioned in the question module, apart from that we get to be more familiar
with modular programming and learn about digital logic circuits as well.

Avash Joshi 1
CS4051NP Fundamentals of Computing

Goals and objectives

 The important goal of this project is the development of a software application that propels to growth
or to greater activity of a digital circuit executing the process of adding integers.
 A state or condition permitting clear perception or understanding of the model construction of a byte
adder using logical electronic gates based on the model of bit adder.
 Including a program, a documentation that clearly explains all the required model, algorithm, data
structures.
 To learn more about the model of bit adder to form byte adder represented through several diagrams.
 Clear visions of the algorithm for adding two integers specified with pseudocodes and flowchart as
well.
 Testing program with proper test cases, and presented with proper testing format so that the program
works absolutely smooth without any errors.
 The enhancement in the skills/knowledge about syntax, variables, decision making statements, data
types, loops, data structures and digital logic circuits.

Avash Joshi 2
CS4051NP Fundamentals of Computing

2. MODEL
The bit adder circuit of the coursework is given below which is implemented by the logical gates
which are NAND, NOR and NOT. The model of a byte adder is constructed based on the given bit
adder model which generates sum and carry. With the help of bit adder, I created a full adder model
circuit and from that the required output can be initialized.

Upper Bit from Lower Bit from


column column

C C

Carry to
next
column
Carry to previous
column
C

Sum
Figure 1: Bit Adder Circuit Model

Adder

An adder is a digital circuit that performs addition of numbers. It is a type of calculator that is used to
add two binary numbers. When I say, calculator that means, this one is a circuit that can be assimilated
with numerous other circuits for a wide range of applications. In many computers and other types of
processors, adders are used to calculate addresses, similar operations and table indices in the ALU and
also in other parts of the processors. There are two kinds of adders classified;

i. Half adder

ii. Full adder


Avash Joshi 3
CS4051NP Fundamentals of Computing

The relationship between the Full-Adder and the Half-Adder is half adder produces results and full adder
uses half adder to produce some other result. Similarly, while the Full-Adder is of two Half-Adders, the
Full-Adder is the actual block that we use to create the arithmetic circuits.

2.1 HALF ADDER


A half adder is a sort of adder that makes a difference within the addition of numbers. It can add two
single binary digits and gives the output additionally a carry value. It has two inputs, called A and B, and
two outputs Sum (S) and Carry (C). It is named as half adder since putting two half adders alongside
with utilize of an OR gate results in a full adder. In another word, it only does half the job of a full adder.

(Techopedia, 2017)

Sum and Carry Out mathematical expressions for half adder.

Sum = A ⊕ B

Carry Out = A.B

A simpler schematic representation of a one-bit half adder is given below:

A Sum
Half
Adder
B Adder Carry
Figure 2: Single Bit Half
Adder

The common representation uses a XOR logic gate and an AND logic gate. Lets have a look at the
implementation of half adder circuit below:

Avash Joshi 4
CS4051NP Fundamentals of Computing

A
Sum
B
C
XOR C

Carry

AND C

Figure 3: Half Adder Circuit

For complex addition, there may be cases when we have to add two 8 -bit bytes together. And this is
possible only with the help of full-adder logic.

With the help of half adder, we can design circuits that are capable of performing simple addition with
the help of logic gates. Let us first take a look at the addition of single bits.

0+0=0

0+1=1

1+0=1

1 + 1 = 10

These are the slightest conceivable single-bit combinations. But the result for 1+1 is 10. In spite of the
fact that this issue can be illuminated with the assistance of an EXOR Gate, the sum result must be re-
written as a 2-bit output. Thus the above equations can be written as

0 + 0 = 00

0 + 1 = 01

Avash Joshi 5
CS4051NP Fundamentals of Computing

1 + 0 = 01

1 + 1 = 10

Here the output ‘1’of ‘10’ becomes the carry-out. The result is shown in a truth-table below. ‘SUM’ is
the normal output and ‘CARRY’ is the carry-out.

Half Adder Truth Table:

INPUTS OUTPUT

A B Sum Carry

0 0 0 0

0 1 1 0

1 0 1 0

1 1 0 1

Table 1: Truth Table of Half Adder

Now, it is clear that this 1-bit adder can be easily implemented with the help of EXOR Gate for the output
‘SUM’ and an AND Gate for the Carry. When we require to add, two 8-bit bytes collectively, we can be
done with the assistance of a full-adder logic. The half-adder is valuable once you need to add one binary
digit amounts. A way to create a two-binary digit adders would be to forma truth table and diminish it.
When you need to form a three binary digit adder, do it once more. When you choose to create a four
digit adder, do it once more. The circuits would be quick, but improvement time is moderate. (Elprocus,
2013)

Avash Joshi 6
CS4051NP Fundamentals of Computing

2.2 FULL ADDER


Full Adder is the type of adder which adds three inputs and produces two outputs. The primary two
inputs are A and B and the third input is an input carry as Cin. The output carry is assigned as Cout and
the ordinary output is assigned as S which is SUM. A full adder logic is outlined in such a way that can
take eight inputs alongside to forma byte-wide adder and cascade the carry bit from one adder to the
other. (Jain, n.d.) The implementation of the full adder is a little more difficult than a half adder. After
designing full adder logic, we will be capable to string eight of them unitedly to obtain a byte-wide adder
and cascade the carry bit from one adder to the subsequent.

Sum and Carry Output mathematical expression for full adder:

Sum = A ⊕ B ⊕ Cin

Carry Out = A.B + (A ⊕ B)Cin

A Cout
B Full Adder
Sum
Cin
Figure 4: Single Bit Full Adder

With this sort of symbol, we can add two bits mutually taking a carry from another lower order of
magnitude, and transferring a carry to the next higher order of magnitude. In a computer, for a multi-bit
operation, each bit must be defined by a full adder and must be added at the same time. Therefore, to add
two 8-bit numbers, we will need 8 full adders that can be created by cascading two of the 4-bit blocks.
The addition of two 4-bit numbers is given below:

Avash Joshi 7
CS4051NP Fundamentals of Computing

Figure 5: Multi-Bit Addition using Full Adder

The addition of two 8-bit numbers:

A7 B7 A6 B6 A5 B5 A4 B4 A3 B3 A2 B2 A1 B1 A0 B0

A B Cin A B Cin A B Cin A B Cin A B Cin A B Cin A B Cin A B Cin

Cout S Cout S Cout S Cout S Cout S Cout S Cout S Cout S

C7 S7 C6 S6 C5 S5 C4 S4 C3 S3 C2 S2 C1 S1 C0 S0

Figure 6: Parallel 8-bit Adder Circuit

Avash Joshi 8
CS4051NP Fundamentals of Computing

Full Adder Truth Table:

INPUTS OUTPUT

A B Cin Cin S

0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1
Table 2: Truth Table of Full Adder

With the truth-table, the full adder logic can be implemented. The output S is an XOR between the input
A and the half-adder, SUM output with B and Cin inputs. We take Cout which will only be true if any of
the two inputs out of the three are HIGH.

Thus, we can design a full adder circuit with the help of two half adder circuits. At first, half adder will
be used to add A and B to create a partial Sum and a second half adder logic can be used to add C in to
the Sum created by the first half adder to obtain the final S output.

Avash Joshi 9
CS4051NP Fundamentals of Computing

XOR
XOR

AND

OR

AND

Figure 7: Full Adder Circuit

Implementation of Full Adder using Half Adders


2 Half Adders and one OR gate is required to implement a Full Adder.

Figure 8: Full Adder using Half Adders

Avash Joshi 10
CS4051NP Fundamentals of Computing

Implementation of Full Adder using NAND gates:

Figure 9: Full Adder using NAND gates

Implementation of Full Adder using NOR gates:


Total 9 NOR gates are required to implement a Full Adder.

Figure 10: Full Adder using NOR gates

Avash Joshi 11
CS4051NP Fundamentals of Computing

2.3 LOGIC GATES

Logic gates are the basic building blocks of any digital system. It is an electronic circuit having one or
many input and only one output. The relationship between the input and the output is based on a
certain logic. Based on this, logic gates are termed as AND gate, OR gate, NOT gate and so on. The
three logic gates used in the byte adder circuit are described below:

 XOR Gate
The output of XOR Gate is high (1) only when one input is high and is low when both of the inputs
are either low (0) or high (1. XOR Gate is used to perform the calculation of sum in the half adders.

Output = A’B + AB’ = A ⊕ B

INPUTS OUTPUT

A B A XOR B
0 0 0

0 1 1

1 0 1

1 1 0

Avash Joshi 12
CS4051NP Fundamentals of Computing

 AND Gate
The output of AND Gate is high (1) only when all the input is high. AND Gate is used to
calculate Carry Output in both the half adders.
Output = A AND B = A.B

INPUTS OUTPUT

A B A AND B

0 0 0

0 1 0

1 0 0

1 1 1

 OR Gate
The output of OR Gate is high (1) when one of the input is high and it is low only when both
the inputs are low (0). OR Gate is used to calculate the final Carry from two carry bit obtained
by two half adders.

Output = A OR B = A + B

Avash Joshi 13
CS4051NP Fundamentals of Computing

INPUTS OUTPUT

A B A OR B

0 0 0

0 1 1

1 0 1

1 1 1

3. ALGORITHM
An algorithm is a set of well-defined instructions or data processing in sequence to solve a problem.
Algorithms can be broadly used in different places like computer programming, mathematics and
everyday lives. It is an arrangement of steps to be taken out for a required output that comes after the
algorithm completed the full process from a certain given input. (Freeman, 2019)

The algorithm of the program for coursework is given below:

Step 1: Start

Step 2: Read first integer value within the range of 0 to 255 and store it.

Step 3: Read second integer value within the range of 0 to 255 and store it.

Step 4: Convert both the integer values into binary and convert the binary numbers to a list of single-
digit bits.

Step 5: Make both the Binary bit list (binary number) of length 8.

Step 6: Initialize Carry in to 0 for the first iteration (for least significant column).

Step 7: Initialize Final Sum to both Binary number and Decimal number and store the value.

Step 8: Load input in the conversion function and then start over from step 1. Keep on the calculation
until the user willing to perform.

Avash Joshi 14
CS4051NP Fundamentals of Computing

Step 9: Join the Final Result list to form a single Binary number and store in another variable Final Sum.

Step 10: Print Sum in both Binary and decimal form.

Step 11: Stop

4. FLOW CHART
A flowchart is a formalized graphic representation of a logic sequence, work or manufacturing process
that explains a process or operation. It incorporates numerous steps, which the process "flows" through
from beginning to ending. Common uses for flowcharts include creating trade plans, characterizing in
defining troubleshooting steps and planning numerical algorithms. Some flowcharts may only include a
couple of steps whereas others can be exceedingly complex, containing hundreds of possible outcomes.

Flowcharts basically use standard symbols to speak to diverse stages or activities inside the chart. For
example, each step is appeared within a rectangle whereas each choice is shown in a diamond. Arrows
are set between the various symbols to display the direction, the process is flowing. (Tech Terms, 2008)

So, the flowchart was created using draw.io and is attached below:-

Avash Joshi 15
CS4051NP Fundamentals of Computing

Figure 11: Flowchart

Avash Joshi 16
CS4051NP Fundamentals of Computing

5. PSEUDOCODE
Pseudocode can be described as an execution of an algorithm within the frame of annotations and
informative content composed in a plain English. It has no sentence structure like every of the
programming dialect and in this way can’t be compiled or translated by the computer. It is a technique
that permits the software engineer to represent the usage of an algorithm. It allows designers or lead
software engineers to precise the plan in extraordinary detail and gives software engineers a nitty-gritty
format for the following step of composing code in a particular programming language.

The pseudocodes for the programs are as follows:

 ‘UserInput’ module

define function UserInput()

while True

try

ask user to input first number value1 after the message “Enter First Integer Number:”

except

if number is invalid print " Error! Please enter an integer value.”

continue

else

if value1 number is greater than 255 or less than 0

print message "Error! Please enter an integer value within the range of 0 to 255."

continue

break

end while block

Avash Joshi 17
CS4051NP Fundamentals of Computing

while True

try

ask user to input second number value2 after the text “Enter second Integer Number:”

except

print " Error! Please enter an integer value.”

continue

else

if value2 number is greater than 255 or less than 0

print message "Error! Please enter an integer value within the range of 0 to 255."

continue

break

end while block

return value1, value2

End function

 Binary module

importing UserInput module

define method BinaryConversion():

Take value1 and value2 from UserInput module

Initialize upBinList = []

Initialize lowBinList = []

Avash Joshi 18
CS4051NP Fundamentals of Computing

while value1 integer is greater than 0

Bin1 = value1 mod 2

Add Bin1 in upBinList

value1 = value1 // 2 (floor division)

while value2 is greater than 0

Bin2 = value1 mod 2

Add Bin2 in lowBinList

value1 = value1 // 2

return Binary_List(upBinList [::-1], lowBinList [::-1])

define Binary_List(List1, List2):

while length(List1) != 8:

Insert (0, 0) in List1

while length(List2) != 8:

Insert (0, 0) in List2

return List1, List2

define Decimal(Binary):

set n = 1

set ans_ = 0

while Binary is greater than 0

Avash Joshi 19
CS4051NP Fundamentals of Computing

R = Binary modulus 10

ans_ = ans_ + n * R

n=n*2

Binary = Binary//10

return ans_

End function

 ‘Adder’ module

importing Binary

define gate _and_(upper_binary, lower_binary)

return upper_binary and lower_binary

define gate _or_(upper_binary, lower_binary)

return upper_binary or lower_binary

define gate _xor_(upper_binary, lower_binary)

return upper_binary^lower_binary

define function Half_Adder(upper_binary, lower_binary)

s_ = _xor_(upper_binary, lower_binary)

c = _and_(upper_binary, lower_binary)

return s_, c

Avash Joshi 20
CS4051NP Fundamentals of Computing

define functionFull_Adder(upper_binary, lower_binary, carry_in)

firstSum, firstCarry = Half_Adder(upper_binary, lower_binary)

secSum, secCarry = Half_Adder(firstSum, carry_in)

c_ = _or_(firstCarry, secCarry)

return secSum, c_

define method _Addition_()

upper_binary, lower_binary = Binary.BinaryVariation()

set default value of carry_in = 0

result = []

for i in range(length(upper_binary)-1, -1, -1)

s_, carry_in = Full_Adder(upper_binary[i], lower_binary[i],carry_in)

result.insert(0, s_)

result.insert(0, carry_in)

result = [str(i) for i in result]

result = int("".join(result))

print the binary value

DecimalValue is the conversion of binary value result

print the decimal value

Call method _Addition_

Avash Joshi 21
CS4051NP Fundamentals of Computing

 ‘Main’ module

importing importlib module

importing UserInput module

importing Binary module

importing Adder module

ask user if they wish to continue or not

while ans is y

importlib.reload(UserInput)

importlib.reload(Binary)

importlib.reload(Adder)

ask user if they want to add more numbers or not

If answer = yes, repeat the while program

If answer = no

End the program

Avash Joshi 22
CS4051NP Fundamentals of Computing

6. DATA STRUCTURE

Data structure is a means of organizing and storing information in order to be accessed and worked with
efficiently. They explain the relationship between the data, and the operations that can be executed on
the data. (Jaiswal, 2017) There are various types of data structures available. The built-ins data structures
are: lists, tuples, dictionaries, strings, sets and frozen sets.
Lists and tuples are ordered sequences of objects. List and tuples can have any sort of objects. Lists and
tuples are like arrays. Lists are mutable hence they can be amplified or decreased at will. Sets are mutable
unordered arrangement of unique components.
Lists are enclosed in brackets:
l = [1, 2, "x"]
Tuples are enclosed in parentheses:
t = (1, 2, "x")
Tuples are faster and consume less memory.

Dictionaries are built with curly brackets:


d = {"x":1, "y":2}
Sets are made using the set () built-in function.
(Cokelaer, 2014)
List is a data structure in Python that is a mutable, or changeable, ordered sequence of elements. Each
element or value that is inside of a list is called an item. Lists are defined by having values between
square brackets [ ].

From these data structures, only List has been applied in my program and its uses are as follows:-

 It is used in my coding for storing various decimal and binary numbers.

 Lists are great to use when we want to work with many related values. So, in my program, List
helped me to keep data together that belongs alongside, condense my code, and performed the
same methods and operations on multiple values at once.

 The list is a flexible data type and has been modified throughout the course of my program. This
program covered the basic features of lists, including indexing, slicing, modifying, and
concatenating lists.

 I have applied list for storing input given by the user and to add “0” in order to make it 8-bits. I
have declared few empty lists in order to store data afterwards when necessary.

Avash Joshi 23
CS4051NP Fundamentals of Computing

 During the conversion of binary and decimal numbers into list of single digit binary bit. Insert
function was used to insert the remainder received while dividing the input integer value.

7. TESTING

Testing is the first important thing for formulating a program where a programmer does not get much
clear thought around in case their program is running as expected or not, until the code is tested
correctly. A programmer ought to carry many tests counting compilation of the code, usefulness of
traits, special case dealing with, and many more so that to begin with of all, the program does not halt
while running, and the program runs as per the desires.

7.1. TEST I

Figure 12: Test I

Avash Joshi 24
CS4051NP Fundamentals of Computing

Objective: To check if the program works when two valid integer numbers
between 0 and 255 are entered.

Action Input two integer numbers between 0 and 255.

Expected Output The program should run without any error and sum of the two integer
numbers should be printed in both binary and decimal form.

Actual Output The sum of the two numbers was displayed in both binary and decimal
values without any error.

Test Result Successful.


Table 3: Test I

7.2. TEST II

Figure 13: Test II

Avash Joshi 25
CS4051NP Fundamentals of Computing

Objective: To check if the program displays appropriate message when user


inputs number greater than 255.

Action Input number greater than 255.

Expected Output Appropriate message pop-ups on the screen.

Actual Output An error occurred and asked user to enter the value within the provided
range.

Test Result Successful.


Table 4: Test II

7.3. TEST III

Figure 14: Test III

Objective: To check if the program runs and displays the sum when the both
integers are minimum values ‘0’

Action Input 0 for both first and second integers.

Expected Output Result of sum of 0 and 0 is 0.

Actual Output The sum of give values was displayed in binary as well as decimal form.

Test Result Successful.


Table 5: Test III

Avash Joshi 26
CS4051NP Fundamentals of Computing

7.4. TEST IV

Figure 15: Test IV

Objective: To check if the program runs or not until the user wants to perform
calculation.

Action After input of two valid numbers, enter ‘y’ for the continuation of the
program and to stop the program enter ‘n’.

Expected Output User should be able to perform numerous calculation and the programs
doesn’t ask user for the input after entering ‘n’.

Actual Output No any errors occurred and the user was able to perform multiple
calculations.

Test Result Successful.


Table 6: Test IV

Avash Joshi 27
CS4051NP Fundamentals of Computing

7.5. TEST V

Figure 16: Test V

Objective: To check if the program gives output when input is negative integer or
an integer greater than 255.

Action Input negative integer and next time input integer greater than 255.

Expected Output Program doesn’t run and shows error.

Actual Output Error occurred and the calculation didn’t work.

Test Result Successful.


Table 7: Test V

Avash Joshi 28
CS4051NP Fundamentals of Computing

7.6. TEST VI

Figure 17: Test VI

Avash Joshi 29
CS4051NP Fundamentals of Computing

Objective: To check if the binary and decimal outputs are either right or wrong.

Action Check the result of both binary and decimal values with the help of online
calculations.

Expected Output The output values displayed on the screen through coding should be
accurate.

Actual Output Output results were correct and the program works flawlessly.

Test Result Successful.


Table 8: Test VI

Avash Joshi 30
CS4051NP Fundamentals of Computing

8. CONCLUSION

Through some relevant researches, online surfing, video tutorial, and practices, I have performed all the
task required in this coursework with all my dedication and as a result, the testimony of documentation
has been furnished as well as the program is working flawlessly and performs the necessary operations
for calculating binary addition. Internet helped me a lot for compact idea to find out the best information
related to the python and byte adder assembled using electronic gates based on the model of the bit adder.

Proper exception handling has been done and code is properly structured in a modular manner. The
program has been well tested with 6 proper test cases, and presented with proper testing format. The
algorithm has been well defined, flowchart and pseudocode are also specifically completed which are
attached within this report. I have constructed a model of a byte adder using logical electronic gates
while being based on the bit adder model given in the coursework. The data structures and digital circuits
have been described nicely with proper examples. And now, I have become more familiar with modular
programming, digital logic circuits, syntax, variables, data types, loops, decision making statements and
and working mechanism of iteration related to this coursework of Python.

In the beginning, I was little bit confused about where to start my coding from. The digital logic circuits,
variables, data structures, loops, decision making statements and more that we have to use were all
unfamiliar to me. I faced problems and errors during the time of my assignment. It was not simple to
analyze where and how to handle exceptions as well as the testing part. Therefore books, seniors and
mostly consoling module teacher, their guidelines was the best idea and help to have better understanding
about the subject matter. It was a great privilege and honor to work and study under their guidance. I am
very much grateful for what they have offered me and it was really encouraging.

To conclude, I am really happy that I have accomplished this project related to python within the given
timeframe. Overall, I am more cleared now about the working mechanism of a byte adder and the
components related to it. The coursework has offered me to figure it out that we need to be working out
more harder and strive for more endless times to perform better in our programming skills/abilities and
steady aptitudes to fulfill our goals.

Avash Joshi 31
CS4051NP Fundamentals of Computing

9. REFERENCES

Cokelaer, T., 2014. Data Structures. [Online]


Available at: https://thomas-cokelaer.info/tutorials/python/data_structures.html
[Accessed 6 June 2020].

Elprocus, 2013. Explain Half Adder and Full Adder with Truth Table. [Online]
Available at: https://www.elprocus.com/half-adder-and-full-
adder/#:~:text=An%20adder%20is%20a%20digital%20circuit%20that%20performs%20addition%20o
f,both%20inputs%20to%20produce%20carry.
[Accessed 5 June 2020].

Freeman, J., 2019. What is Algorithm. [Online]


Available at: https://www.edrawsoft.com/algorithm-definition.html
[Accessed 5 June 2020].

Jain, S., n.d. Full Adder in Digial Logic. [Online]


Available at: https://www.geeksforgeeks.org/full-adder-in-digital-logic/
[Accessed 5 June 2020].

Jaiswal, S., 2017. Python Data Structures Tutorial. [Online]


Available at: https://www.datacamp.com/community/tutorials/data-structures-python
[Accessed 6 june 2020].

Janssen, D., 2019. Python. [Online]


Available at: https://www.techopedia.com/definition/3533/python
[Accessed 1 June 2020].

Tech Terms, 2008. Flowchart. [Online]


Available at: https://techterms.com/definition/flowchart
[Accessed 5 June 2020].

Techopedia, 2017. Half Adder. [Online]


Available at: https://www.techopedia.com/definition/7509/half-
adder#:~:text=A%20half%20adder%20is%20a,)%20and%20C%20(carry).
[Accessed 5 June 2020].

Avash Joshi 32
CS4051NP Fundamentals of Computing

Avash Joshi 33

You might also like