Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Looping: Array Operators Example Name Result

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

Looping

The while loop is used to repeat a section of code an unknown number of times until a specific condition
is met. For example, say we want to know how many times a given number can be divided by 2 before it
is less than or equal to 1. If we know a specific number, such as 32, we can say 5 times, but for a given
symbolic variable "NUMBER" which represents any number in the world, how many times is not known
a priori (before hand). In this case, we could use a while loop to determine that answer

a do while loop is a control flow statement that executes a block of code at least once, and then either
repeatedly executes the block, or stops executing it, depending on a given Boolean condition at the end
of the block.

The for loop is used to repeat a section of code known number of times. Sometimes it is the computer
that knows how many times, not you, but it is still known

List and Arrays

An array is a sequenced collection of elements of the same data type with a single identifier name.
Python lists are similar to arrays in other languages but are not restricted to a single data type. The term
‘array’ as used in this chapter will generally also apply to Python lists unless otherwise noted.

Arrays can have multiple axes (more than one axis). Each axis is a dimension. Thus, a single-dimension
array is also known as a list. A two-dimension array is commonly known as a table (a spreadsheet like
Excel is a two-dimension array). In real life, there are occasions to have data organized into multiple-
dimension arrays. Consider a theater ticket with section, row, and seat (three dimensions). Most single-
dimension arrays are visualized vertically.

Most programmers are familiar with a special type of array called a string. Strings are basically a single
dimension array of characters. Unlike other single dimension arrays, we usually envision a string as a
horizontal stream of characters and not vertically as a list.

We refer to the individual values as members (or elements) of the array. Programming languages
implement the details of arrays differently. Because there is only one identifier name assigned to the
array, we have operators that allow us to reference or access the individual members of an array. The
operator commonly associated with referencing array members is the index operator. It is important to
learn how to define an array and initialize its members.

Array Operators
Example Name Result
$a + $b Union Union of $a and $b.
$a == $b Equality true if $a and $b have the same key/value pairs.
$a === Identity true if $a and $b have the same key/value pairs in the same order and of the same types
Array Operators
Example Name Result
$b
$a! = $b Inequality true if $a is not equal to $b.
$a <> $b Inequality true if $a is not equal to $b.
$a! == $b Non-identity true if $a is not identical to $b.

Debugging Techniques

Debugging Process

The process of finding bugs or errors and fixing them in any application or software is called debugging.
To make the software programs or products bug-free, this process should be done before releasing
them into the market. The steps involved in this process are,

1.Identifying the error – It saves time and avoids the errors at the user site. Identifying errors at an
earlier stage helps to minimize the number of errors and wastage of time.

2.Identifying the error location – The exact location of the error should be found to fix the bug faster
and execute the code.

3.Analyzing the error – To understand the type of bug or error and reduce the number of errors we
need to analyze the error. Solving one bug may lead to another bug that stops the application process.

4.Prove the analysis – Once the error has been analyzed, we need to prove the analysis. It uses a test
automation process to write the test cases through the test framework.

5.Cover the lateral damage – The bugs can be resolved by making the appropriate changes and move
onto the next stages of the code or programs to fix the other errors.

6.Fix and validate – This is the final stage to check all the new errors, changes in the software or
program and executes the application.

Debugging Tools

A software tool or program used to test and debug the other programs is called a debugger or a
debugging tool. It helps to identify the errors of the code at the various stages of the software
development process. These tools analyze the test run and find the lines of codes that are not executed.
Simulators in other debugging tools allow the user to know about the display and behavior of the
operating system or any other computing device. Most of the open-source tools and scripting languages
don’t run an IDE and they require the manual process.

Mostly used Debugging Tools are GDB, DDD, and Eclipse.


GDB Tool: This type of tool is used in Unix programming. GDB is pre-installed in all Linux systems if not, it
is necessary to download the GCC compiler package.

DDD Tool: DDD means Data Display Debugger, which is used to run a Graphic User Interface (GUI) in
Unix systems.

Eclipse: An IDE tool is the integration of an editor, build tool, debugger and other development tools.
IDE is the most popular Eclipse tool. It works more efficiently when compared to the DDD, GDB and
other tools.

You might also like