Programming Assignment: Algorithms, Programming Paradigms, and Debugging in Python
VerifiedAdded on 2024/05/21
|25
|3668
|173
AI Summary
This assignment explores fundamental programming concepts, including algorithms, programming paradigms, and debugging techniques. It delves into the practical application of these concepts using Python, a versatile and widely used programming language. The assignment covers topics such as algorithm design, procedural programming, object-oriented programming, event-driven programming, and the use of the IDLE integrated development environment (IDE) for debugging. Through hands-on exercises and code examples, students will gain a comprehensive understanding of these essential programming principles and develop the skills necessary to write efficient and error-free Python code.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
PROGRAMMING ASSIGNMENT
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Contents
LO1:............................................................................................................................................................2
P1: ALGORITHM...................................................................................................................................2
M1: Pseudo Code:...................................................................................................................................4
LO2:............................................................................................................................................................5
P2:...........................................................................................................................................................5
PROCEDURAL PROGRAMMING:......................................................................................................5
OBJECT-ORIENTATED:.......................................................................................................................5
EVENT-DRIVEN:..................................................................................................................................6
M2:..........................................................................................................................................................8
FEATURES OF IDLE.............................................................................................................................8
LO3:............................................................................................................................................................9
P3:...........................................................................................................................................................9
M3:........................................................................................................................................................13
LO4:..........................................................................................................................................................14
P4: a) debugging process.......................................................................................................................14
P4-b) Coding Standards:........................................................................................................................19
M4:........................................................................................................................................................23
REFERENCES:.........................................................................................................................................24
1
LO1:............................................................................................................................................................2
P1: ALGORITHM...................................................................................................................................2
M1: Pseudo Code:...................................................................................................................................4
LO2:............................................................................................................................................................5
P2:...........................................................................................................................................................5
PROCEDURAL PROGRAMMING:......................................................................................................5
OBJECT-ORIENTATED:.......................................................................................................................5
EVENT-DRIVEN:..................................................................................................................................6
M2:..........................................................................................................................................................8
FEATURES OF IDLE.............................................................................................................................8
LO3:............................................................................................................................................................9
P3:...........................................................................................................................................................9
M3:........................................................................................................................................................13
LO4:..........................................................................................................................................................14
P4: a) debugging process.......................................................................................................................14
P4-b) Coding Standards:........................................................................................................................19
M4:........................................................................................................................................................23
REFERENCES:.........................................................................................................................................24
1
LO1:
P1: ALGORITHM
An algorithm is a procedure for solving the programs, it tells us about the specification of the
class program. Algorithms can perform mathematical operations, calculations, data processing
and tells us about the flow of the program and how the task is performing.
The algorithm starts from the initial stage and goes to the final stage. It tells us about the time
complexity and space complexity of the program.
Basically, there are 8 types of the algorithm:
1. Simple recursive algorithm: the Simple recursive algorithm is an algorithm in which repeat
itself. It divides the problem into simple subproblem.
2. Backtracking algorithm: It will backtrack the path for defining the best solution. If no
solution is given by backtracking, return failure.
3. Divide and Conquer: Divide and conquer algorithm consist of two parts:
-Divide: It divides the problem into the smaller subproblem.
-Conquer- It integrates the result of subproblem into the one for giving the solution to the
original problem.
4. Binary Tree lookup: In this, we look up the sorted binary tree, three cases
- If both the keys are equal, return success.
- If the key value is less than look up for left subtree.
-If the key value is greater than look up for right subtree.
Repeat the process till success is return.
5. Dynamic programming algorithm: In this algorithm, the old results are saved and the new
result is found using the old results.
6. Greedy Algorithm: the Greedy algorithm is used to find the best-optimized result, it works in
two-phase
- We will choose the best and proceed
- We find the local optimum and global optimum.
2
P1: ALGORITHM
An algorithm is a procedure for solving the programs, it tells us about the specification of the
class program. Algorithms can perform mathematical operations, calculations, data processing
and tells us about the flow of the program and how the task is performing.
The algorithm starts from the initial stage and goes to the final stage. It tells us about the time
complexity and space complexity of the program.
Basically, there are 8 types of the algorithm:
1. Simple recursive algorithm: the Simple recursive algorithm is an algorithm in which repeat
itself. It divides the problem into simple subproblem.
2. Backtracking algorithm: It will backtrack the path for defining the best solution. If no
solution is given by backtracking, return failure.
3. Divide and Conquer: Divide and conquer algorithm consist of two parts:
-Divide: It divides the problem into the smaller subproblem.
-Conquer- It integrates the result of subproblem into the one for giving the solution to the
original problem.
4. Binary Tree lookup: In this, we look up the sorted binary tree, three cases
- If both the keys are equal, return success.
- If the key value is less than look up for left subtree.
-If the key value is greater than look up for right subtree.
Repeat the process till success is return.
5. Dynamic programming algorithm: In this algorithm, the old results are saved and the new
result is found using the old results.
6. Greedy Algorithm: the Greedy algorithm is used to find the best-optimized result, it works in
two-phase
- We will choose the best and proceed
- We find the local optimum and global optimum.
2
7. Branch and bound method: used for the optimization problem, upper bound and lower
bound are constructed.
8. Brute force algorithm: This algorithm works till the satisfactory result is generated.
9. Randomized algorithm: Random value is used to make the decision.
ALGORITHM:
Step 1 : Start
Step 2: Array_Sum = 0
Step 3: for v in Arrays:
Array_Sum = Array_Sum+v
3
bound are constructed.
8. Brute force algorithm: This algorithm works till the satisfactory result is generated.
9. Randomized algorithm: Random value is used to make the decision.
ALGORITHM:
Step 1 : Start
Step 2: Array_Sum = 0
Step 3: for v in Arrays:
Array_Sum = Array_Sum+v
3
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Step 4: return Array_Sum
Start 5: Stop
M1: Pseudo Code:
Pseudocode is an informal code or a description of a code written in a high-level language. It is
written for the human so that after reading this code they have the basic idea of the program and
start and programming accordingly.
The pseudo code consists of instructions; instruction means actions which are going to perform
in the program. Hence we can say that pseudo code is a detailed step of the programming
development.
It makes the task easy; we can easily convert the pseudocode into a programming language.
The pseudo code starts with the ‘begin’ and ends with the ‘end’ which specify the starting and
end of the programming. The pseudo code makes the programming easier. It is key to
developing the complex and long program, all the part of the program can be mentioned in the
pseudo code.
PSEUDO CODE FOR BOUNCING BALL:
STEP 1: BEGIN
STEP 2: Enter the height of the ball;
STEP 3: Assign count =0 ;
STEP 4: if ball_height>0.5
Then,
Ball_height= 0.75 * ball_height
STEP 5: count = count + 1;
While true (GOTO step 4);
STEP 6: print bounce of the ball i.e. count ;
STEP 7: END
4
Start 5: Stop
M1: Pseudo Code:
Pseudocode is an informal code or a description of a code written in a high-level language. It is
written for the human so that after reading this code they have the basic idea of the program and
start and programming accordingly.
The pseudo code consists of instructions; instruction means actions which are going to perform
in the program. Hence we can say that pseudo code is a detailed step of the programming
development.
It makes the task easy; we can easily convert the pseudocode into a programming language.
The pseudo code starts with the ‘begin’ and ends with the ‘end’ which specify the starting and
end of the programming. The pseudo code makes the programming easier. It is key to
developing the complex and long program, all the part of the program can be mentioned in the
pseudo code.
PSEUDO CODE FOR BOUNCING BALL:
STEP 1: BEGIN
STEP 2: Enter the height of the ball;
STEP 3: Assign count =0 ;
STEP 4: if ball_height>0.5
Then,
Ball_height= 0.75 * ball_height
STEP 5: count = count + 1;
While true (GOTO step 4);
STEP 6: print bounce of the ball i.e. count ;
STEP 7: END
4
LO2:
P2:
PROCEDURAL PROGRAMMING:
The procedural language also called “Imperative Language”. A procedural language is a
language which composed of well-structured series and procedures within its programming
module. It consists of methodical or organized functions, sub routines, operations and statements
that should be executed in computational tasks. We can define the procedural language as the
simple language where we just write the simple computer statement to execute. These statements
need to be organizing in particular formats. This is basically known as development of
subroutines. In an imperative language, these subroutines are known as ’procedures’. Procedures
are the small programs that can be called from any other programs. Procedures are intended to do
some specific tasks. Then the procedure is called the current execution of the program is stored
in the register and execution of the procedure takes place. After the execution of the procedure,
the execution returns to the line where the procedure is called. The procedure is used to reduce
the size of the program and the developer need not write the same code again and again. The
procedural language can be written using three things only:
• Sequence
• Selection statements, for example: if statement
• Iterative statements, for example, loops
AS the name procedural implies, it as predefined and well defined functions and procedures that
should be executed to reach the output. C/C++are the example of the procedural language.
In python, procedural language is one of its coding styles. In this task are treated as the iteration
and the common task are placed in the function which is called. This coding style includes
iteration, selection, modularization of code and statements (DeLine and Leino, 2005).
OBJECT-ORIENTATED:
Object-oriented programming concern about the modeling or objects rather than actions and data
rather than logic. In object-oriented programming, it takes care of the object than manipulate that
object.
In object-oriented programming, the initial step is to find the object and how they are related to
each other. This step is known as data modeling. After analyzing the objects, we generalized the
class that means we define the kind of data contains and the logical sequences. Logical
5
P2:
PROCEDURAL PROGRAMMING:
The procedural language also called “Imperative Language”. A procedural language is a
language which composed of well-structured series and procedures within its programming
module. It consists of methodical or organized functions, sub routines, operations and statements
that should be executed in computational tasks. We can define the procedural language as the
simple language where we just write the simple computer statement to execute. These statements
need to be organizing in particular formats. This is basically known as development of
subroutines. In an imperative language, these subroutines are known as ’procedures’. Procedures
are the small programs that can be called from any other programs. Procedures are intended to do
some specific tasks. Then the procedure is called the current execution of the program is stored
in the register and execution of the procedure takes place. After the execution of the procedure,
the execution returns to the line where the procedure is called. The procedure is used to reduce
the size of the program and the developer need not write the same code again and again. The
procedural language can be written using three things only:
• Sequence
• Selection statements, for example: if statement
• Iterative statements, for example, loops
AS the name procedural implies, it as predefined and well defined functions and procedures that
should be executed to reach the output. C/C++are the example of the procedural language.
In python, procedural language is one of its coding styles. In this task are treated as the iteration
and the common task are placed in the function which is called. This coding style includes
iteration, selection, modularization of code and statements (DeLine and Leino, 2005).
OBJECT-ORIENTATED:
Object-oriented programming concern about the modeling or objects rather than actions and data
rather than logic. In object-oriented programming, it takes care of the object than manipulate that
object.
In object-oriented programming, the initial step is to find the object and how they are related to
each other. This step is known as data modeling. After analyzing the objects, we generalized the
class that means we define the kind of data contains and the logical sequences. Logical
5
sequences are known as methods. Objects communicate with each other through messages.
Following are the characteristics of the object-oriented programming:
• We can make the subclasses of the class which shares the some or all characteristics of the
main class. This property of OOPS is known as inheritance. This basically reduces the
development time and provides efficient coding. There is various type of inheritance like single
inheritance, multiple inheritance, multipath inheritance, multilevel inheritance and hierarchical
inheritance.
• Only the necessary data is accessed, other data is hidden. This property is known as Data
Hiding. This basically increases the security of the code. Only public data member can be
accessed by the other functions. Private data members are limited to their scope.
• When only essential information is visible to the user and other information is hidden from
them. This property is known as Data Abstraction. This basically simplifies the software
development.
The user does not know about the hidden information.
• Binding of data and function into the single entity is another characteristic of the OOPS. This
property is known as Data Encapsulations. This safe the data from misuse.
• Poly refers to ‘many’ and morphism refers to ‘ways’. Hence polymorphism means ‘many
ways’. In object-oriented programming, different objects can respond to the same functions and
the behavior is identified at the runtime. This property is known as polymorphism. Function
overloading and operator overloading is used to achieve polymorphism.
In python, object-oriented programming coding style is used to reduce the code length and to
increase the reusability of the code (Smith, 2015).
EVENT-DRIVEN:
As the name suggest the program structure and execution depends upon the event in the program.
The handling of these events is required, the procedure Is known as event driven handling. We
can use any programming language to write event driven programming code.
6
Following are the characteristics of the object-oriented programming:
• We can make the subclasses of the class which shares the some or all characteristics of the
main class. This property of OOPS is known as inheritance. This basically reduces the
development time and provides efficient coding. There is various type of inheritance like single
inheritance, multiple inheritance, multipath inheritance, multilevel inheritance and hierarchical
inheritance.
• Only the necessary data is accessed, other data is hidden. This property is known as Data
Hiding. This basically increases the security of the code. Only public data member can be
accessed by the other functions. Private data members are limited to their scope.
• When only essential information is visible to the user and other information is hidden from
them. This property is known as Data Abstraction. This basically simplifies the software
development.
The user does not know about the hidden information.
• Binding of data and function into the single entity is another characteristic of the OOPS. This
property is known as Data Encapsulations. This safe the data from misuse.
• Poly refers to ‘many’ and morphism refers to ‘ways’. Hence polymorphism means ‘many
ways’. In object-oriented programming, different objects can respond to the same functions and
the behavior is identified at the runtime. This property is known as polymorphism. Function
overloading and operator overloading is used to achieve polymorphism.
In python, object-oriented programming coding style is used to reduce the code length and to
increase the reusability of the code (Smith, 2015).
EVENT-DRIVEN:
As the name suggest the program structure and execution depends upon the event in the program.
The handling of these events is required, the procedure Is known as event driven handling. We
can use any programming language to write event driven programming code.
6
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Figure 1: Event driven programming
In event-driven programming, the schedule is a central element which receives a stream of
events and sends the events to the appropriate event handler. If there is no such event handler
than scheduler either ignore it or throw an exception. An event handler is responsible for the
execution of the events.
Characteristics of event-driven programming are as follows:
• Service-oriented: services run in the background of the OS. It consumes computer processing
power but does not slow down the computer.
• Time Driven: time driven means that the code runs at a specific time only, the time is
specified.
• Event handler: Event handler is used to run the specific event when the specific time is
triggered.
• Simplicity of programming: Even driven programming is simple and easy to develop as we
can use any programming language to write the event-driven programming. Easy for user to
insert the code into the pre-existing file.
Difference between event driven, OOPS and procedural language:
PROCEDURAL
LANGUAGE
OBJECT ORIENTED
PROGRAMMING
EVENT DRIVEN
PROGRAMMING
Structure of the program
define the execution of the
program
Objects are the major concern Event define the flow of the
program
Describe how Step by step
processing is done
Describe the interconnection
between different objects
Handles the external events
Example: FORTAN, COBOL Example: java, c++ Example: c, C#
7
In event-driven programming, the schedule is a central element which receives a stream of
events and sends the events to the appropriate event handler. If there is no such event handler
than scheduler either ignore it or throw an exception. An event handler is responsible for the
execution of the events.
Characteristics of event-driven programming are as follows:
• Service-oriented: services run in the background of the OS. It consumes computer processing
power but does not slow down the computer.
• Time Driven: time driven means that the code runs at a specific time only, the time is
specified.
• Event handler: Event handler is used to run the specific event when the specific time is
triggered.
• Simplicity of programming: Even driven programming is simple and easy to develop as we
can use any programming language to write the event-driven programming. Easy for user to
insert the code into the pre-existing file.
Difference between event driven, OOPS and procedural language:
PROCEDURAL
LANGUAGE
OBJECT ORIENTED
PROGRAMMING
EVENT DRIVEN
PROGRAMMING
Structure of the program
define the execution of the
program
Objects are the major concern Event define the flow of the
program
Describe how Step by step
processing is done
Describe the interconnection
between different objects
Handles the external events
Example: FORTAN, COBOL Example: java, c++ Example: c, C#
7
M2:
FEATURES OF IDLE
• This is cross-platform that means can be used on any platform like in UNIX and Windows.
• IDLE support multi-window text editor.
• It gives different colorizing, smart indent and call tips.
• Its supports the shell window i.e. have an interactive interpreter.
• It supports the powerful debugger.
• Provide Ease to navigate the code.
• Highlights the error.
• This IDE always reopens from the same state, when you left.
• This IDE supports the automatic code formatting, that means, know about the next line that
should be intended in the code. This is done by recognizing the colon at the end of the line.
8
FEATURES OF IDLE
• This is cross-platform that means can be used on any platform like in UNIX and Windows.
• IDLE support multi-window text editor.
• It gives different colorizing, smart indent and call tips.
• Its supports the shell window i.e. have an interactive interpreter.
• It supports the powerful debugger.
• Provide Ease to navigate the code.
• Highlights the error.
• This IDE always reopens from the same state, when you left.
• This IDE supports the automatic code formatting, that means, know about the next line that
should be intended in the code. This is done by recognizing the colon at the end of the line.
8
LO3:
P3:
9
P3:
9
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
10
11
12
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
M3:
As we know that, IDLE is the best IDE for the python and full of features that makes the
development of software easy. We found the IDLE as the best development tool for the python.
It is full of features and we enjoyed working with IDLE. Understanding of IDE is given below:
We get to know about how IDLE can run on different platform i.e. windows and Linux.
I understand about the debugging process in IDLE python
I learn about the concept of breakpoint, step and go. We can debug the source code as a
single line instruction or by setting the breakpoint so that code can execute at normal
speed.
I learned how to set the breakpoint.
Understanding of editor is easy.
There are no extra commands to compile and execute the program. Hence this makes the
compilation and execution easy.
We understand the concept of code navigation, used to combine programming services
Highlighted texts made this IDE effective and I understand the use of highlighted text
which helps in fixing space/tabs related issues.
Graphical user interface is user friendly and easy to understand.
13
As we know that, IDLE is the best IDE for the python and full of features that makes the
development of software easy. We found the IDLE as the best development tool for the python.
It is full of features and we enjoyed working with IDLE. Understanding of IDE is given below:
We get to know about how IDLE can run on different platform i.e. windows and Linux.
I understand about the debugging process in IDLE python
I learn about the concept of breakpoint, step and go. We can debug the source code as a
single line instruction or by setting the breakpoint so that code can execute at normal
speed.
I learned how to set the breakpoint.
Understanding of editor is easy.
There are no extra commands to compile and execute the program. Hence this makes the
compilation and execution easy.
We understand the concept of code navigation, used to combine programming services
Highlighted texts made this IDE effective and I understand the use of highlighted text
which helps in fixing space/tabs related issues.
Graphical user interface is user friendly and easy to understand.
13
LO4:
P4: a) debugging process
IDLE has its own debugger which is built into IDLE itself. It is useful to see the changes when
values vary.
STEP 1: Open the python shell
Figure 2: python shell
STEP 2: Click on the debug option from the menu bar at the top and select the debugger. Then a
debug window will appear on the screen.
14
P4: a) debugging process
IDLE has its own debugger which is built into IDLE itself. It is useful to see the changes when
values vary.
STEP 1: Open the python shell
Figure 2: python shell
STEP 2: Click on the debug option from the menu bar at the top and select the debugger. Then a
debug window will appear on the screen.
14
Figure 3: Debugging window
STEP 3: Now we have to set the breakpoints in the code to use the debugger at its best before
running the program. Breakpoint is like a condition for the debugger who tells to slow down the
speed to normal speed and let the human have the control. There can be more than one
breakpoint in a code. To set the breakpoint, right click on the line and select the breakpoint.
15
STEP 3: Now we have to set the breakpoints in the code to use the debugger at its best before
running the program. Breakpoint is like a condition for the debugger who tells to slow down the
speed to normal speed and let the human have the control. There can be more than one
breakpoint in a code. To set the breakpoint, right click on the line and select the breakpoint.
15
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Figure 4: Set breakpoint
STEP 4: When you select the ‘set breakpoint’, the lines will turn yellow.
Figure 5: Yellow color indicates the breakpoint
STEP 5: If there is no breakpoint in your code, then the debugger will stop at the first line and
pause the debugging at the first line of the executable code but after that will run the code
without any pause.
16
STEP 4: When you select the ‘set breakpoint’, the lines will turn yellow.
Figure 5: Yellow color indicates the breakpoint
STEP 5: If there is no breakpoint in your code, then the debugger will stop at the first line and
pause the debugging at the first line of the executable code but after that will run the code
without any pause.
16
STEP 6: Click on ‘GO’ button at the top of the debugging window, this will execute the program
until next breakpoint occurs.
Figure 6: 'GO' is used to encounter the breakpoint
STEP 7: Again click on ‘GO’ to encounter the next breakpoint. And the debugging will show
that the next breakpoint is encountered.
17
until next breakpoint occurs.
Figure 6: 'GO' is used to encounter the breakpoint
STEP 7: Again click on ‘GO’ to encounter the next breakpoint. And the debugging will show
that the next breakpoint is encountered.
17
Figure 7 Again click on go to encounter next breakpoint
STEP 8: When all the breakpoint has encountered, the result will be displayed on the python
shell. If there is any bug than debugger will resolve that bug. If not then final output will be
displayed.
Figure 8: Final Output
DEBUGGING FACILITIES:
18
STEP 8: When all the breakpoint has encountered, the result will be displayed on the python
shell. If there is any bug than debugger will resolve that bug. If not then final output will be
displayed.
Figure 8: Final Output
DEBUGGING FACILITIES:
18
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
There is a debugging facility available in the IDLE tool. We can debug the code in two ways in
this IDLE. First method is stepping. In stepping, single instruction is executed at a time. For this
we have to click on the ‘STEP’ button at the top of the debug window. After clicking, the python
will execute the first instruction. Now, we will repeat the same step. Click the ‘QUIT’ button to
terminate the program.
To execute more than one import lines, click the ‘STEP’ button twice.
To execute the three def statements, click ‘STEP’ button thrice.
To define the playAgain variable. Click ‘STEP’ button again and again.
If we want the program to run normally, then we will use ‘GO’ button instead of ‘STEP’ button.
The speed of execution is normal and ‘QUIT’ button is used to terminate the program.
We can even set the breakpoints when we want the debugger to take control once reaches at that
line. If we are not assured about the correctness of the line than we mark the line as a breakpoint.
We debugger finds any bug, than will resolve that bug at that time only and will continue the
execution. The execution will be at normal speed until the next breakpoint. Process will repeat
until all the breakpoint has encountered (McDowell and Helmbold, 1989).
P4-b) Coding Standards:
Coding standards are used to increase the readability efficiency of the code. That means, if some
other person is reading our code than he can easily understand our code. Following are the
coding standard that we have used in your code:
We use the comments in our code. Comments are of two types- single line comment and
multi-line comment. When the comment is of one line then we use single line comment
and when comment is of more than one line then we use multi-line comment. Comments
should be short. It should not be too difficult for developers to understand your code.
Long comments are unnecessary and make your code look complex. Comments increase
the readability efficiency of the code. Other can easily understand the code if we uses the
comments to explain the code in short.
We have followed the rules of identifier to name them. Like, no space is used between
the name of the identifier, did not started the name with the underscore etc.
19
this IDLE. First method is stepping. In stepping, single instruction is executed at a time. For this
we have to click on the ‘STEP’ button at the top of the debug window. After clicking, the python
will execute the first instruction. Now, we will repeat the same step. Click the ‘QUIT’ button to
terminate the program.
To execute more than one import lines, click the ‘STEP’ button twice.
To execute the three def statements, click ‘STEP’ button thrice.
To define the playAgain variable. Click ‘STEP’ button again and again.
If we want the program to run normally, then we will use ‘GO’ button instead of ‘STEP’ button.
The speed of execution is normal and ‘QUIT’ button is used to terminate the program.
We can even set the breakpoints when we want the debugger to take control once reaches at that
line. If we are not assured about the correctness of the line than we mark the line as a breakpoint.
We debugger finds any bug, than will resolve that bug at that time only and will continue the
execution. The execution will be at normal speed until the next breakpoint. Process will repeat
until all the breakpoint has encountered (McDowell and Helmbold, 1989).
P4-b) Coding Standards:
Coding standards are used to increase the readability efficiency of the code. That means, if some
other person is reading our code than he can easily understand our code. Following are the
coding standard that we have used in your code:
We use the comments in our code. Comments are of two types- single line comment and
multi-line comment. When the comment is of one line then we use single line comment
and when comment is of more than one line then we use multi-line comment. Comments
should be short. It should not be too difficult for developers to understand your code.
Long comments are unnecessary and make your code look complex. Comments increase
the readability efficiency of the code. Other can easily understand the code if we uses the
comments to explain the code in short.
We have followed the rules of identifier to name them. Like, no space is used between
the name of the identifier, did not started the name with the underscore etc.
19
Uses the capital letters to declare constants. Like, PI=3.14.
Start the function name with the capital letters. For example Average(). This basically
used to identify the functions.
We give the meaningful name to the functions and the identifiers. For example if I want
to find the area of the rectangle then the function name should be Area().
Def Area(Length, width):
area_rectangle = Length*width
return ( area_rectangle) ;
As we know that python is case sensitive, ‘Grades’ and ‘grades’ are not equal.
We use the exception handling in our program, so that the execution of the program does
not interrupted if any exception is occurred during the run-time.
We have used the proper indentation and line spacing in our code. Proper indentation is
used to analyze the proper scope of the function in the program. For example:
Type 1
if (g < 18 && h < 25 || i < 61) { return true; } else {System.out.println (“incorrect value”)
; return false; }
Type 2
if (g < 18 && h < 25 || i < 61)
{
return true;
}
else
{
System.out.println(“incorrect value”);
return false;
}
Hence, we can say that type2 is the proper example of indentation (Mitchell, 2004).
20
Start the function name with the capital letters. For example Average(). This basically
used to identify the functions.
We give the meaningful name to the functions and the identifiers. For example if I want
to find the area of the rectangle then the function name should be Area().
Def Area(Length, width):
area_rectangle = Length*width
return ( area_rectangle) ;
As we know that python is case sensitive, ‘Grades’ and ‘grades’ are not equal.
We use the exception handling in our program, so that the execution of the program does
not interrupted if any exception is occurred during the run-time.
We have used the proper indentation and line spacing in our code. Proper indentation is
used to analyze the proper scope of the function in the program. For example:
Type 1
if (g < 18 && h < 25 || i < 61) { return true; } else {System.out.println (“incorrect value”)
; return false; }
Type 2
if (g < 18 && h < 25 || i < 61)
{
return true;
}
else
{
System.out.println(“incorrect value”);
return false;
}
Hence, we can say that type2 is the proper example of indentation (Mitchell, 2004).
20
We used the random operators in our code.
Proper iteration and loops is used in the code
Proper modules and packages our import to our code
21
Proper iteration and loops is used in the code
Proper modules and packages our import to our code
21
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
22
M4:
Debugging is the only technique to detect and remove the errors in a source code that can
interrupt the execution of the code during the runtime. Even our software behaves unexpectedly
or crash. To protect the software from this crash, debugging is used resolve these bugs from the
source code. Debugger tool is used to identify the problem. To debug the given program, the
user has to start with the problem, then isolate the problem and fix it. After fixing the bug,
software is ready to use. Steps to debug the program are given below:
1. Analyze the code and recognize the bug if exists.
2. Isolate the bug from the source.
3. Identify the reason of the bug.
4. Then will try to fix the bug.
5. After fixing the bug, we will again test the code.
Following are the characteristics of the Debugging process can be used to help develop more
secure, robust applications:
1. Breakpoints: If we are not assured about the correctness of the line than we mark the
line as a breakpoint. We debugger finds any bug, than will resolve that bug at that time
only and will continue the execution. The execution will be at normal speed until the next
breakpoint. Process will repeat until all the breakpoint has encountered.
2. Go, Step: When we want the normal execution the of the program, we uses GO and if we
want single instruction is executed at a time, we use STEP.
3. View the call stack: By using this, we can see the list of functions and procedures in the
stack.
4. Local/global scope: local and global scope of the variable is defined and the address
space is allocated to them.
5. Edit variable content: Debugger will edit the content pr optimize the content of the
variable so that application continues to operate without any interruption.
23
Debugging is the only technique to detect and remove the errors in a source code that can
interrupt the execution of the code during the runtime. Even our software behaves unexpectedly
or crash. To protect the software from this crash, debugging is used resolve these bugs from the
source code. Debugger tool is used to identify the problem. To debug the given program, the
user has to start with the problem, then isolate the problem and fix it. After fixing the bug,
software is ready to use. Steps to debug the program are given below:
1. Analyze the code and recognize the bug if exists.
2. Isolate the bug from the source.
3. Identify the reason of the bug.
4. Then will try to fix the bug.
5. After fixing the bug, we will again test the code.
Following are the characteristics of the Debugging process can be used to help develop more
secure, robust applications:
1. Breakpoints: If we are not assured about the correctness of the line than we mark the
line as a breakpoint. We debugger finds any bug, than will resolve that bug at that time
only and will continue the execution. The execution will be at normal speed until the next
breakpoint. Process will repeat until all the breakpoint has encountered.
2. Go, Step: When we want the normal execution the of the program, we uses GO and if we
want single instruction is executed at a time, we use STEP.
3. View the call stack: By using this, we can see the list of functions and procedures in the
stack.
4. Local/global scope: local and global scope of the variable is defined and the address
space is allocated to them.
5. Edit variable content: Debugger will edit the content pr optimize the content of the
variable so that application continues to operate without any interruption.
23
REFERENCES:
DeLine, R. and Leino, K.R.M., 2005. BoogiePL: A typed procedural language for checking
object-oriented programs.
Smith, B., 2015. Object-oriented programming. In Advanced ActionScript 3 (pp. 1-23).
Apress, Berkeley, CA.
McDowell, C.E. and Helmbold, D.P., 1989. Debugging concurrent programs. ACM
Computing Surveys (CSUR), 21(4), pp.593-622.
Mitchell, J.L., 2004. Introduction to digital audio coding and standards. Journal of Electronic
Imaging, 13(2), p.399.
24
DeLine, R. and Leino, K.R.M., 2005. BoogiePL: A typed procedural language for checking
object-oriented programs.
Smith, B., 2015. Object-oriented programming. In Advanced ActionScript 3 (pp. 1-23).
Apress, Berkeley, CA.
McDowell, C.E. and Helmbold, D.P., 1989. Debugging concurrent programs. ACM
Computing Surveys (CSUR), 21(4), pp.593-622.
Mitchell, J.L., 2004. Introduction to digital audio coding and standards. Journal of Electronic
Imaging, 13(2), p.399.
24
1 out of 25
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.