Tag Archives: Python

Flow Control Statements

(Click the below link for a Microsoft Word version of this blog-post)

flow_control_statement

(Click the below link for a pdf version of this blog-post)

flow_control_statement

 

if_jpeg_segment

Figure 1: I drew the above segment of a Flowchart Algorithm in Microsoft Word.

In programming, statements such as:

if

, which introduce a condition, are known as:

flow-control statements

.

One way to conceive of Computer Algorithms, is to represent them as Flowcharts.  The:

if

statement alters or controls the flow of the algorithm.

In the above depicted example[1], if the condition tested by the:

if

statement should be found to be true, then the logical execution of the algorithm will flow down the left-hand side of the page.

In the above depicted example, if the condition tested by the:

if

statement should be found to be true, then the logical execution of the algorithm will flow down the left-hand side of the page.

In the above depicted example, if the condition tested by the:

if

statement should be found to be false, then the logical execution of the algorithm will flow down the right-hand side of the page.

When we introduce a logical split into our algorithm, then this is termed:

‘branching’

.

The true and false tributaries of the depicted flow-chart algorithm are termed:

‘branches’

.

branching

Figure 2:  The algorithm branches.  We can instruct the computer to do different tasks depending upon whether the logical condition tested by the if statement be found true or false.

if_jpeg_segment

Figure 3:  In this segment of a Flowchart Algorithm, we can see that it branches after we test a logical condition with an if statement.  In the depiction, above, we can observe the true branch of the Algorithm, and the false branch of the Algorithm.  I drew the above illustration in Microsoft Paint.

algo_second_version_final

Figure 4: I drew this flow-chart algorithm in Microsoft Word.

In Figure 4, we have a flow-chart algorithm that describes a program that takes an integer – either a 1 or a 0 – inputted by the user, and which outputs a string contingent upon what the user has inputted.

The above algorithm solves a computational problem.  The computational problem that the above algorithm solves may be stated as:

 How can we test a litteral inputed by a user so as to see if it should equate to Boolean True or Boolean False?

Mutual Exclusion:

The:

true

 and:

 false

branches of this algorithm are termed:

‘mutually exclusive’

.

A logical test is performed, and if that which is tested be true then that excludes the possibility of its being false.

A logical test is performed, and if that which is tested be false then that excludes the possibility of its being true.

If the true branch of the algorithm be executed, then the false branch of the algorithm will not be executed.

If the false branch of the algorithm be executed, then the true branch of the algorithm will not be executed.

Branching in Python:

We shall now write a program in Python that corresponds to the algorithm depicted in Figure 4.

python_branch_program_final

Figure 5:  This is the python program that corresponds to the algorithm in Figure 4.

output_0_false

Figure 6:  This is what is outputted by the Python program depicted in Figure 5 should the user input the value, 0.

output_1_true

Figure 7:  This is what is outputted by the Python program depicted in Figure 5 should the user input the value, 1.

output_2_invalid_boolean_input

Figure 8:  This is what is outputted by the Python program depicted in Figure 5 should the user input a literal that is not a 1 or a 0.

More on Branching in Algorithms in General:

As we can see from the algorithm depicted on Page 5, the:

true

and:

false

branches of the algorithm converge or attain a confluence prior to the:

“Goodbye!”

string’s being outputted.

The:

“Goodbye!”

string will be outputted regardless of the result of the logical condition tested by the:

if

statement.

Back to If Statements in Python:

One quintessential piece of Python syntax is the colon.  The colon is used to declare that what follows will be an indented code block.

colon_black_pen

Figure 9:  In Python, if statements are always terminated by colons.  In Python, the colon always declares that the preceding code block will be indented.  The code block that follows the colon that terminates the if statement is indented[2].  I drew the above image with pens.

Back to Branching in Algorithms in General:

Trees are not the only things that branch.  Rivers also branch into tributaries.  Rivers also flow downwards[3], and so it is an excellent analogy so as to conceive of branching in algorithms.

branching_river

Figure 10:  Another way to conceive of branching in flow-chart algorithms: the flow-chart algorithm branches into true and false code blocks after a logical condition is tested, before re-attaining a confluence prior to “Goodbye” being printed.  The two tributaries of the flow-chart algorithm merge together again prior to “Goodbye” being printed.  Regardless of whether the true code block or the false code block be executed, “Goodbye” will nonetheless be printed.

What is the Purpose of Writing an Algorithm prior to Writing a Program?

An algorithm is imperative[4] knowledge.  It tells one how to do something.  In computing, an algorithm tells one how to solve a computational problem.

In computing, an algorithm is a series of commands that solves a computational problem.

There are two approaches to programming:

Seat-of-the-Pants Method:

With this method, the programmer just dives into writing the program.  However, the programmer still composes an algorithm, only this time, the algorithm is mental.  At each stage of his writing a program, the programmer still must imagine what he must command the computer to do for it to solve a computational problem.  The programmer just does not take the time to write this series of commands or algorithm down.

Write-the-Algorithm-First Method:

With this method, the programmer solves the computational problem first prior to his commencing writing the program.  He does this by writing an algorithm.

The advantage of writing an algorithm is that it does not limit the programmer to a solution in a single language such as Python.  Should the programmer take the time to write out the algorithm first, then it will allow him to easily compose a program that corresponds to that algorithm not only in Python, but in whatever programming language that he should so choose.

Writing a Program that Corresponds to our Algorithm in C:

In Figure 4, we wrote an algorithm that solved a computational problem.  The computational problem that was solved by the algorithm depicted in Figure 4 can be stated as:

How can we test a litteral inputed by a user so as to see if it should equate to Boolean True or Boolean False?

With the above-stated computational problem solved, we can now easily write a program that corresponds to the algorithm, not only in Python syntax, but in C syntax, as well.

c_program_true_false_code_final

Figure 11:  The C program that corresponds to the algorithm depicted in Figure 4.

 

output_0_false_c

Figure 12:  What the C program depicted in Figure 11 outputs should the user input a 0.

output_1_true_c

Figure 13:  What the C program depicted in Figure 11 outputs should the user input a 1.

output_2_invalid_boolean_input_c

Figure 14:  What the C program depicted in Figure 11 outputs should the user input a literal that is neither a 0 or a 1.

Glossary:

confluence

  • noun. the junction of two rivers, especially rivers of approximately equal width.
    • an act or process of merging: a major confluence of the world’s financial markets.

<ORIGIN> late Middle English: from late Latin confluentia, from Latin confluere ‘flow together’ (see CONFLUENT).[5]

<ETYMOLOGY>  From the Latin 1st-declension feminine noun, ‘conflŭentĭa, conflŭentĭae,’ which means ‘a flowing together.’[6]  From the Latin preposition, ‘cum,’ which means ‘together;’ and the Latin 3rd-conjugation verb, ‘fluō, fluere, fluxī, fluxum,’ which means ‘to flow;’ and the Latin 1st-declension nominal suffix, ‘-tia, -tiae,’ which denotes a state of being.  A confluence, therefore, etymologically, is ‘a flowing together.’

As regards algorithms, by way of an analogy, a confluence can be said to describe the merging of two or more branches of a flow-chart algorithm.

 

 

 

confluent

  • adjective. flowing together or merging.

<ORIGIN> late 15th century: from Latin confluent- ‘flowing together’, from confluere, from con- ‘together’ + fluere ‘to flow’.[7]

<ETYMOLOGY>  From the Latin 3rd-declension masculine noun, ‘cōnfluēns, cōnfluēntis,’ ‘ which means ‘confluence.’ ‘flowing together.’  From the Latin preposition, ‘cum,’ which means ‘together;’ and the Latin present active participle, ‘fluēns, fluēntis,’ which means ‘flowing.’

 

As regards algorithms, by way of an analogy, two or more branches of an algorithm can be said to be confluent when they merge together.

 

 

imperative

  • adjective.
  1. of vital importance;crucial:  immediate action was imperative | [with clauseit is imperative that standards are maintained.
  2. giving an authoritative command; peremptory:the bell pealed again, a final imperative call.
  • [GRAMMAR] denoting the mood of a verb that expresses a command or exhortation, as income here!
  • noun.
  1. an essential or urgent thing:free movement of labour was an economic imperative.
  • a factor or influence making something necessary:the biological imperatives which guide male and female behaviour.
  1. [GRAMMAR] a verb or phrase in the imperative mood.
  • (the imperative) the imperative mood.

<DERIVATIVES> imperatival adjective.  imperatively adverb.  imperativeness noun.

<ORIGIN> late Middle English (as a grammatical term): from Late Latin imperativus (literally ‘specially ordered’, translating Greek prostatikē enklisis ‘imperative mood’), from imperare ‘to command’, from in- ‘towards’ + parare ‘make ready’[8].

 

<ETYMOLOGY>  from the Latin 1st-and-2nd-declension adjective, ‘impĕrātīva, impĕrātīvus, impĕrātīvum,’ which means ‘pertaining to the command;’ ‘of the command.’  From the Latin 1st-conjugation verb, ‘imperō, imperāre, imperāvī, imperātum,’ which means ‘to command,’ ‘to order,’ and the Latin 1st-and-2nd-declension adjectival suffix ‘-īva, -īvus, -īvum,’ which means ‘of,’ ‘concerning,’ ‘pertaining to.’  From the Latin prefix ‘in-’ which expresses the concept of ‘unto,’ ‘toward,’ and the Latin 1st-conjugation verb, ‘parō, parāre, parāvī, parātum,’ which means ‘to make ready,’ ‘to prepare.’  The etymological sense, therefore, of the English adjective, ‘imperative’ is: ‘concerning the command;’ ‘pertaining to the command;’ ‘of the command;’ ‘concerning the order;’ ‘pertaining to the order;’ ‘of the order;’ ‘concerning the making ready of;’ ‘pertaining to the making ready of;’ ‘of the making ready of;’ etc.

 

As regards algorithms, ‘imperative’ denotes the type of knowledge expressed by a series of commands, as opposed to declarative knowledge.

 


[1] i.e. the example depicted in Figure 1.

[2]  In Python style, an indent is worth 4 spaces.

[3]  As does a flow-chart algorithm.

[4]  From the Latin 1st-conjugation verb, ‘imperō, imperāre, imperāvī, imperātum,’ which means: ‘to command,’ ‘to order.’  Cp.  Latin English Lexicon: Optimized for the Kindle, Thomas McCarthy, (Perilingua Language Tools: 2013) Version 2.1  Loc 46105.

[5]  Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford.  2010.  Loc 146068.

[6]  Cp.  Latin English Lexicon: Optimized for the Kindle, Thomas McCarthy, (Perilingua Language Tools: 2013) Version 2.1  Loc 23064.

[7]  Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford.  2010.  Loc 146082.

[8]   ibid.  Loc 345790

What is a Code Block?

(Click the below link for a Microsoft Word version of this blog-post)

what_is_a_code_block

(Click the below link for a pdf version of this blog-post)

what_is_a_code_block

In Python, a code block is defined as a number of sequential statements, or lines of code, that share the same level of indentation.

In Python Style, an indent is defined as four spaces.

When starting out learning how to program, your programs will consist of a single block of code.

code_block_final

Figure 1:  When learning how to program, you will probably begin to code simple calculators such as the calculator depicted above that converts degrees Celsius into degrees Fahrenheit. The above program consists of merely 1 block of code comprising 7 lines. As you can observe, all seven lines share the same level of indentation.

code_block_final_output

Figure 2: What the code depicted in Figure 1 looks like when interpreted and used.

However, whenever you attain to a greater level of programming ability that will allow you to code programs with greater complexity and sophistication, then more than one block of code will be required:

temperature_converter_code_final

Figure 3: This calculator does much the same thing as the calculator depicted in Figures 1 & 2. It is a lot more complex and sophisticated, though. As we may observe, the above-depicted program comprises several blocks of code. We know this to be the case because the program contains various levels of indentation. The blocks of code that are to be executed when this program is run is contingent upon what the user inputs.

temperature_converter_output_final

Figure 4: What the program depicted in Figure 3 looks like when interpreted and used.

Floor Division in Python

(Click the below link for a Microsoft Word version of this blog-post)

floor_division_in_python

(Click the below link for a pdf version of this blog-post)

floor_division_in_python

floor_division_operator

Figure 1:  The Floor-Division operator.  In Python, the Floor-Division operator consists of two forward slashes.  The Floor-Division operator is an example of a binary operator, as it takes two operands: the dividend and the divisor.

With floor division, one number, the dividend, is divided by another number, the divisor, and the result, or quotient – whatever it may happen to be – will be a rounded-down integer value.

Let us consider the Python Equation:

>>>8/5

1.6

>>>

The number, 8, the dividend, is divided by the divisor, 5, and a floating-point number, 1.6, is then returned as a quotient.

eight_divided_by_five_shell_ordinary_division

Figure 2:  When we divide 8 by 5 using the division operator, / , then a floating-point number, 1.6, is returned as a quotient.

division_operator

Figure 3:  This is our Division operator.  When we employ this binary operator, a floating-point number will be returned.

Whenever we employ a Division operator in Python, then a floating point number will always be returned as a quotient, even if the quotient has no significant fractional component.

eight_divided_by_four_shell_ordinary_division

Figure 4:  Whenever we divide the dividend, 8, by the divisor, 4, then the quotient, 2.0, is still returned as a floating-point number despite its not having any significant fractional component.

Let us, again, consider the Python equation:

>>>8/5

1.6

>>>

, but let us do things a little differently:

>>>8//5

1

>>>

In the above example, we have now employed the floor-division operator.  The floor-division operator will always return an integer value, if the 2 operands that it takes be integers.

eight_divided_by_five_shell_floor_division

Figure 5:  When we divide the dividend, 8, by the divisor, 5, we get the quotient, 1, rendered as an integer.

Let us consider 8 divided by 2 in ordinary arithmetic for a moment:

8 ÷ 5 = 1.6

In the above example, we divide an integer by an integer and we obtain a real number as a result, or quotient.

If we wanted a less precise answer, then it would be customary to see:

8 ÷ 5 2

In normal arithmetic, it would be customary to round:

1.6

up to:

2

.

However, in floor division, floating point numbers such as:

>>>1.6

1.6

>>>

are always rounded down to the value of its integral component.

So, in Python, the floor value of:

>>>1.6

1.6

>>>

would be:

>>>2

2

>>>

The floor-division operator will always return an integer as a quotient, unless floating-point numbers be employed as operands.

seven_point_nine_divided_by_three_point_two_shell_ordinary_division

Figure 6:  When we divide 7.9 by 3.2 in conventional division, we obtain the floating-point quotient, 2.46875

seven_point_nine_divided_by_three_point_two_shell_floor_division

Figure 7:  When we divide 7.9 by 3.2 in floor division, we still obtain a floating-point quotient, 2.0, but it does not have a significant fractional component.

Programming a Floor-Division Calculator in Python:

In the following section, we shall program a simple floor-division calculator in Python:

floor_division_calculator

Figure 8:  A simple floor-division calculator programmed in Python.  This program requests that the user input two numbers.  The program then takes these inputs; divides the dividend by the divisor; and then returns a rounded-down quotient.

output_floor_division_calculator_final

Figure 9:  What the previous program, depicted in Figure 8, outputs when run.

 

 

Integer Multiplication in Python.

(Click the below link for a Microsoft Word version of this blog-post)

integer_multiplication_python

(Click the below link for a pdf version of this blog-post)

integer_multiplication_python

x_multiplication_symbol_300dpi

Figure 1:  The Multiplication symbol.  This symbol is used as a Multiplication Operator in Mathematics, but not as a Multiplication Operator in programming languages such as Python.

asterisk_300dpi

Figure 2:  Instead of an ‘X’ symbol, we employ the asterisk symbol as a multiplication operator in Python.  Press the keyboard key with this symbol depicted on it so as to effect multiplication.

asterisk_python_font_300dpi

Figure 3:  What the asterisk symbol looks like rendered in Python’s default font.

What goes on, Arithmetically, in Multiplication?

In Arithmetic, Multiplication, is one of the four elementary operations.  We ought to examine what occurs, arithmetically, in integer multiplication.

 

Let us take the equation:

2 × 4 = 8

.  We pronounce the above equation, in English, as:

Two multiplied by four is equal to eight.

In the above equation, the integer, 2, is the multiplicand[1].  The integer, 2, is what is being multiplied by 4.  I looked up the word ‘multiplication’ in a Latin dictionary[2], and its transliterated equivalent gave:

‘to make many,’

as a definition.

In the above equation, the:

×

symbol is termed ‘the multiplication operator.’  To restate: ‘operator’ is Latin for ‘worker.’  It is the multiplication operator that facilitates the ‘operation’ or ‘work’ of multiplication.  In Python, we use the:

*

, or asterisk symbol, as a multiplication operator.  In Python, the multiplication operator is known as a ‘binary operator[3]’ as it takes two operands.  The operands, in question, are:

2

, the multiplicand, and:

4

, the multiplier.

In the Python equation:

>>> 2 * 4

8.0

>>>

The multiplicand, 2, and the multiplier, 4, are the two operands that the binary operator:

*

takes.

two_asterisk_four_shell

Figure 4:  In Python, we use the * symbol as a multiplication operator.  This is common to most programming languages.  In the above example, we have multiplied 2 by 4, and have got the product, 8.

Let us return to the equation:

2 × 4 = 8

In the above equation,

4

is termed ‘the multiplier.’  In English, the ‘-er’ suffix denotes the agent, or doer of an action.  It is the:

4

that is doing the dividing.  2 is being multiplied by 4.

In the equation:

2 × 4 = 8

the:

=

, or “equals sign,” is termed ‘the sign of equality.’  The sign of equality or equality operator tells us that 2 multiplied by 4 is equal to 8.

In the equation:

2 × 4 = 8

, 8 is termed ‘the product.’  The product is simply the result of multiplication.

The term, ‘product,’ comes from the Latin, ‘to lead forth.’[4]

The result of 2 being multiplied by 4 is 8, so, therefore, 8 is the product.

If we were doing ‘Sums’ in primary school, then:

8

, the product, would be our answer.

Integer Multiplication in Python

In this section, we shall program a simple Integer-Multiplication Calculator in Python.

integer_multiplication_calculator_final

Figure 5:  In the above-depicted program, we have programmed a simple Integer-Multiplication Calculator that requests the user to input a Multiplicand and a Multiplier, which are the two binary operands of the Multiplication Operator.  The Integer-Multiplication Calculator then returns a product.

output_integer_multiplication_calculator_final

Figure 6:  What the Integer-Multiplication Calculator, as depicted in Figure 5, outputs when we, the user, input the Multiplicand, 2, and the Multiplier, 4.  As we can see, the program outputs the product, 8.

Glossary:

-er

  • suffix
    1. denoting a person or thing that performs a specified action or activity: farmer | sprinkler
    2. denoting a person or thing that has a specified attribute or form: foreigner | two-wheeler.
    3. denoting a person concerned with a specified thing or subject: milliner | philosopher.
    4. denoting a person belonging to a specified place or group: city-dweller | New Yorker.

<ORIGIN> Old English -ere, of Germanic origin.

 

-ion

  • suffix forming nouns denoting verbal action: communion.
    • denoting an instance of this: a rebellion.
    • denoting a resulting state or product: oblivion | opinion.

<ORIGIN>  via French from Latin -ion-.

<USAGE> The suffix -ion is usually found preceded by s (-sion), t (-tion), or x (-xion).[5]

<ETYMOLOGY> From the Latin 3rd-declension nominal suffix, ‘-iō, -ōnis’.

 

-ious

  • suffix (forming adjectives) characterized by; full of: cautious | vivacious.

<ORIGIN> from French -ieux, from Latin -iosus.[6]

<ETYMOLOGY> From the Latin 1st-and-2nd-declension adjectival suffix, ‘-iōsa, -iōsus, -iōsum.’

 

-ity

  • suffix forming nouns denoting quality or condition: humility | probity.
    • denoting an instance or degree of this: a profanity.

<ORIGIN> from French -ité, from Latin -itas, -itatis.

<ETYMOLOGY> From the Latin 3rd-declension nominal suffix ‘-itās, itātis.’

 

equation

    1. [MATHEMATICS] a statement that the values of two mathematical expressions are equal (indicated by the sign =)
    2. [mass noun] the process of equating one thing with another: the equation of science with objectivity.
      • (the equation) a situation in which several factors must be taken into account: money also came into the equation.
    3. [CHEMISTRY] a symbolic representation of the changes which occur in a chemical reaction, expressed in terms of the formulae of the molecules or other species involved.

<PHRASES>

  • equation of the first (or second etc.) order [MATHEMATICS] an equation involving only the first derivative, second derivative, etc.

<ORIGIN> late Middle English: from Latin aequatio-(n-), from aequare ‘make equal’ (see EQUATE).[7]

<ETYMOLOGY> from the Latin 1st-and-2nd-declension adjective, ‘æqua, æquus, æquum,’ which means ‘equal;’ and the 3rd-declension nominal suffix, ‘-tiō, (-tiōnis),’ which denotes a state of being.  Therefore, etymologically, an ‘equation’ is ‘a state of being equal.’  Etymologically, therefore, an ‘equation’ is a mathematical statement that declares terms to be equal.


 

multiple

  • adjective.

having or involving several parts, elements, or members: multiple occupancy | a multiple pile-up | a multiple birth.

  • numerous and often varied: words with multiple meanings.
  • (of a disease, injury, etc.) complex in its nature or effects; affecting several parts of the body: a multiple fracture of the femur.
  • noun.
    1. a number that may be divided by another a certain number of times without a remainder: 15, 20, or any multiple of five.
    2. (also multiple shop or store)

BRITISH a shop with branches in many places, especially one selling a specific type of product.

<ORIGIN> mid 17th century: from French, from late Latin multiplus, alteration of Latin multiplex (see MULTIPLEX).[8]

<ETYMOLOGY> From the Latin 3rd-declension adjective, ‘multiplex, multiplicis’ which means ‘manifold.’  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave.’

 

 

multiplex

    1. involving or consisting of many elements in a complex relationship: multiplex ties of work and friendship.
      • involving simultaneous transmission of several messages along a single channel of communication.
    2. (of a cinema) having several separate screens within one building.
  • verb. [with object] incorporate into multiplex signal or system.

<DERIVATIVES> multiplexer (also multiplexor) noun.

<ORIGIN> late Middle English in the mathematical sense ‘multiple’: from Latin.[9]

<ETYMOLOGY> From the Latin 3rd-declension adjective, ‘multiplex, multiplicis’ which means ‘manifold.’  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave.’

 

 

multipliable

  • adjective. able to be multiplied.[10]

multiplicable

  • adjective. able to be multiplied

<ORIGIN> late 15th century: from Old French, from medieval Latin multiplicabilis, from Latin, from multiplex, multilplic- (see MULTIPLEX).

<ETYMOLOGY> From the Latin 3rd-declension adjective, ‘multiplicābilis, multiplicābile,’ which means ‘manifold.’  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave;’ and the Latin 3rd-declension adjective, ‘habilis, habile,’ which means ‘having.’  The Latin 3rd-declension adjective, ‘habilis, habile,’ is the adjectival form of the Latin 2nd-declension verb, ‘habeō, habēre, habuī, habitum,’ which means ‘to have.’  The etymological meaning of the term, ‘multipliable,’ therefore, is ‘having the ability to be multiplied;’ ‘having the ability to be made many;’ ‘having the ability to be made manifold.’

multiplicand

  • noun. a quantity which is to be multiplied by another (the multiplier).

<ORIGIN> late 16th century: from medieval Latin multiplicandus ‘to be multiplied’, gerundive of Latin multiplicare (see multiply1).[11]

<ETYMOLOGY>  From the Latin 1st-declension verb, ‘multiplicō, multiplicāre, multiplicāvī, multiplicātum,’ which means ‘to multiply, increase, augment.’  ‘Multiplicandum est’ is the neuter gerundive form.  It means ‘that which must be multiplied;’ ‘that which must be made many.’

 

 

 

multiplication

  • noun. [mass noun] the process or skill of multiplying.
    • [MATHEMATICS] the process of combining matrices, vectors, or other quantities under specific rules to obtain their product.

<ORIGIN> late Middle English: from Old French, or from Latin: multiplication(n-), from multiplicare (see multiply1)[12]

<ETYMOLOGY>  From the Latin 3rd-declension feminine noun, ‘multĭpĭcātĭo, multĭpĭcātĭōnis,’ which means ‘a making manifold,’ ‘increasing,’ ‘multiplying.’  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave;’ and the Latin 3rd-declension nominal suffix, ‘-iō, -ōnis’, which signifies a noun denoting a verbal action.  Therefore, the etymological definition of ‘multiplication’ is: ‘the action of multiplying;’ ‘the action of making many;’ ‘the action of making manifold;’ etc.

multiplication sign

  • noun. the sign , used indicate that one quantity is to be multiplied by another, as in .[13]

multiplication table

  • noun. a list of multiples of a particular number, typically from 1 to 12.[14]


 

multiplicative

  • adjective. subject to or of the nature of multiplication: coronary risk factors are multiplicative.[15]

<ETYMOLOGY>  From the Latin 1st-and-2nd-declension adjective, ‘multiplicātiva, multiplicātivus, multiplicātivum,’ which means ‘of multiplication;’ ‘of the action of making many;’ etc.  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave;’ and the Latin 1st-and-2nd-declension nominal suffix, ‘-īva, – īvus, -īvum’, which signifies ‘of,’ ‘concerning’.  Therefore, the etymological definition of the English adjective, ‘multiplicative,’ is ‘concerning multiplication;’ ‘concerning the action of making many;’ ‘denoting multiplication;’ ‘denoting the action of making many;’ ‘of multiplication;’ ‘of the action of making many;’ etc.

multiplicity

  • noun. (plural. multiplicities) a large number or variety: the demand for higher education depends on a multiplity of

<ORIGIN> late Middle English: from late Latin multiplicitas, from Latin multiplex (see MULTIPLEX).[16]

<ETYMOLOGY> From the Late Latin 3rd-declension feminine noun, ‘multĭplĭcĭtas, multĭplĭcĭtātis,’ which means ‘multiplicity, manifoldness.’  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave;’ and the Latin 3rd-declension nominal suffix, ‘-itās, itātis,’ which signifies a state of being.  Therefore, the etymological meaning of the English term, multiplicity, is ‘the state of being many;’ ‘the condition of being many;’ etc.

 

 

 

multiplier

  • noun.
    1. a quantity by which a given number (the multiplicand) is to be multiplied.
      • [ECONOMICS] a factor by which an increment of income exceeds the resulting increment of saving or investment.
    2. a device for increasing by repetition the intensity of an electric current, force, etc. to a measurable level.[17]

<ETYMOLOGY> From the English verb ‘to multiply,’ which means ‘to make manifold,’ and the English nominal suffix ‘-er,’ which denotes the performer of an action.  From the Latin 1st-and-2nd-declension adjective ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave;’ and the English suffix ‘-er,’ which denotes the performer of an action.  Therefore, the etymological definition of ‘multiplier’ is ‘the number that multiplies.’

 

 

multiply1

  • verb. (multiplies, multiplying, multiplied) [with object.]
    1. obtain from (a number) another which contains the first number a specified number of times: multiply fourteen by nineteen | [no object] we all know how to multiply by ten.
    2. increase or cause to increase greatly in number or quantity: [no object] ever since I became a landlord my troubles have multiplied tenfold | cigarette smoking combines with other factors to multiply the risks of atherosclerosis.
      • [no object] (of an animal or other organism) increase in number by reproducing.
      • [with object.] propagate (plants).

<ORIGIN>  Middle English: from Old French multiplier, from Latin multiplicare.[18]

<ETYMOLOGY>  From the Latin 1st-conjugation verb, ‘multiplicō, multiplicāre, multiplicāvī, multiplicātum,’ which means ‘to multipliy,’ ‘to increase,’ ‘to augment.’  From the Latin 1st-and-2nd-declension adjective, ‘multa, multus, multum,’ which means ‘many;’ and the Latin 3rd-conjugation verb, ‘plectō, plectere, plexī, plexum,’ which means ‘to plait,’ ‘to interweave.’  Therefore, the etymological definition of the English verb, ‘to multiply,’ is ‘to make manifold;’ ‘to make many;’ etc.

 

 

 

operator

  1. [MATHEMATICS] a symbol or function denoting an operation (e.g. ).[19]

<ETYMOLOGY>  From the 3rd-declension masculine Latin noun, ‘ŏpĕrātor, ŏpĕrātōris,’ which means ‘operator,’ ‘worker.’  The Latin 3rd-declension noun, ‘opus, operis,’ which means ‘work,’ ‘labour.’  From the Latin 1st-conjugation verb, ‘operō, operāre, operāvī, operātor;’ and the 3rd-declension nominal suffix, ‘-or,       (-ōris)’ which denotes a performer of an action.  Etymologically, as regards Mathematics, it is the operator that is said to perform the work of the operation.

 

operation

  • noun.

[mass noun] the action of functioning or the fact of being active or in effect: restrictions on the operation of market forces | the company’s first hotel is now in operation.

  1. [MATHEMATICS] a process in which a number, quantity, expression, etc., is altered or manipulated according to set formal rules, such as those of addition, multiplication, and differentiation.

<ORIGIN> late Middle English: via Old French from Latin operatio(n-), from the verb operari ‘expend labour on’ (see Operate)[20]

 

<ETYMOLOGY>  From the Latin 3rd-declension feminine noun, ‘ŏpĕrātĭo, ŏpĕrātĭōnis,’ which means ‘a working,’ ‘a work,’ ‘a labour,’ ‘operation.’  From the Latin 1st-declension deponent verb ‘operor, operāre, operātus sum,’ which means ‘to work,’ ‘to labour,’ ‘to expend labour on;’ and the Latin 3rd-declension nominal suffix, ‘-iō, (-iōnis),’ which denotes a state of being.  Etymologically, therefore, as regards Mathematics, an ‘operation’ is a ‘mathematical work;’ ‘mathematical working;’ a ‘mathematical labour.’  The mathematical work that would be carried out depends on the operator.  For instance, if the operator be a plus sign, then the mathematical work to be carried out would be addition.  Addition is a type of operation.

produce

  1. [GEOMETRY], DATED extend or continue (a line).

<ORIGIN> late Middle English (in sense 3 of the verb) from Latin producere, from pro- ‘forward’ + ducere ‘to lead’.  Current noun senses date from the late 17th century.[21]

<ETYMOLOGY> From the Latin 3rd-conjugation verb, ‘prōdūcō, prōdūcere, prōdūxī, prōductum’ which means ‘to lead forth;’ ‘to bring forth;’ From the Latin preposition, ‘prō,’ which means ‘forth,’ ‘forward;’ and the Latin 3rd-conjugation verb, ‘dūcō, dūcere, dūxī, ductum,’ meaning ‘to lead.’  Therefore the etymological definition of the English verb, ‘to produce,’ is ‘to lead forth;’ ‘to bring forth;’ etc.


 

product

  • noun.
  1. [MATHEMATICS] a quantity obtained by multiplying quantities together, or from analogous algebraic operation.

<ORIGIN> late Middle English (as a mathematical term): from Latin productum ‘something produced’, neuter past participle (used as a noun) of producer ‘bring forth’ (see PRODUCE).[22]

<ETYMOLOGY> From the Latin participle ‘prōductum,’ which means ‘a leading forth;’ ‘a bringing forth;’ etc.  From the Latin 3rd-conjugation verb, ‘prōdūcō, prōdūcere, prōdūxī, prōductum’ which means ‘to lead forth;’ ‘to bring forth;’ From the Latin preposition, ‘prō,’ which means ‘forth,’ ‘forward;’ and the Latin 3rd-conjugation verb, ‘dūcō, dūcere, dūxī, ductum,’ meaning ‘to lead.’  Therefore the etymological definition of the English verb, ‘to produce,’ is ‘to lead forth;’ ‘to bring forth;’ etc.  Hence the etymological definition of the English noun, ‘product’ is ‘[the result that is] brought forth [from the operation of multiplication];’ etc.

 

 

 


[1]  There seems to be some debate as to whether it be the first term – in this instance 2 – that is the multiplicand, or the second term – in this instance 4.  However, the way that I worded it: “two multiplied by four” leaves us in no doubt that it is the first term – in this instance 2 – that is the multiplicand.

[2]  multiplex icis, adj

[multus + PARC-], with many folds, much-winding: alvus…

Latin English Lexicon: Optimized for the Kindle, Thomas McCarthy, (Perilingua Language Tools: 2013) Version 2.1  Loc 62571.

Hence ‘multiplication,’ etymologically, means ‘to make manifold.’

See GLOSSARY

[3]  See the chapter on UNARY AND BINARY OPERATORS

[4]  The Latin 3rd-conjugation verb, ‘prōdūcō, prōdūcere, prōdūxī, prōdūctum.’  From the Latin preposition, ‘prō,’ meaning ‘forth,’ ‘forward;’ and the Latin 3rd-conjugation verb, ‘dūcō, dūcere, dūxī, ductum,’ meaning ‘to lead.’  The etymological meaning of ‘product,’ therefore, seems to be: ‘[the result,] that which is lead forth [from the process of multiplication].’

[5]  Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc 362341.

[6]  ibid.  Loc 362542.

[7]  ibid.  Loc 234861

[8]  ibid.  Loc 461693.

[9]  ibid.  Loc 461727.

[10]  ibid.  Loc 461740.

[11]  ibid.  Loc 461758.

[12]  ibid.  Loc 461781.

[13]  ibid.  Loc 461787.

[14]  ibid.  Loc 461790.

[15]  ibid.  Loc 461792.

[16]  ibid.  Loc 461805.

[17]  ibid.  Loc 461810.

[18]  ibid.  Loc 461817.

[19]  ibid.  Loc 493860.

[20]  ibid.  Loc 493797.

[21]  ibid.  Loc 560683.

[22]  ibid.  Loc 560753.

Integer Division in Python.

(Click the below link for a Microsoft Word version of this blog-post)

integer_division_python

(Click the below link for a pdf version of this blog-post)

integer_division_python

division_operator_cropped_300dpi

 

Figure 1:  The Division symbol.  This symbol is used as a Division Operator in Mathematics, but not as a Division Operator in programming languages such as Python.

What goes on, Arithmetically, in Division?

Division, in Arithmetic, is one of the four elementary operations.  We ought to examine what occurs, arithmetically, in integer division.

 

Let us take the equation:

8 ÷ 4 = 2

.  We pronounce the above equation, in English, as:

Eight divided by four is equal to two.

In the above equation, the integer, 8, is the dividend.  The integer, 8, is what is being divided up 4 ways.  I looked up the word ‘division’ in a Latin dictionary[1], and its transliterated equivalent gave:

‘to distribute,’

as a definition.  8 elements, the dividend, is being distributed amongst 4 sets, leaving 2 elements – the quotient – in each set.

At the end of the financial year, a portion of a company’s profits is divided up between the company’s shareholders.  This money that is divided up is termed a ‘dividend.’  The term, ‘dividend,’ comes from the Latin gerundive phrase, ‘dividendum est,’ which means ‘that which must be divided.’  In the above equation, it is the integer, 8, that must be divided.

In the above equation, the:

÷

symbol is termed ‘the division operator.’  To restate: ‘operator’ is Latin for ‘worker.’  It is the division operator that facilitates the ‘operation’ or ‘work’ of division.  In Python, we use the:

/

, or forward-slash symbol, as a division operator.  In Python, the division operator is known as a ‘binary operator’ as it takes two operands.  The operands, in question, are:

8

, the dividend, and:

4

, the divisor.

In the Python equation:

> > >8 / 4

2.0

> > >

The dividend, 8, and the divisor, 4, are the two operands that the binary operator:

/

takes.

integer_division_shell

 

Figure 2:  In python, we use the / symbol as a division operator.  This is common to most programming languages.  In the above example, we have divided 8 by 4, and have got the quotient, 2.0.

Let us return to the equation:

8 ÷ 4 = 2

In the above equation,

4

is termed ‘the divisor.’  In Latin, the ‘-or’ suffix denotes the agent, or doer of an action.  It is the:

4

that is doing the dividing.  8 is being divided by 4.

In the equation:

8 ÷ 4 = 2

the:

=

, or “equals sign,” is termed ‘the sign of equality.’  The sign of equality or equality operator tells us that 8 divided by 4 is equal to 2.

In the equation:

8 ÷ 4 = 2

, 2 is termed ‘the quotient.’  The quotient[2] is simply the result of division.

The result of 8 being divided 4 ways is 2, so, therefore, 2 is the quotient.

If we were doing ‘Sums’ in primary school, then:

2

, the quotient, would be our answer.

Integer Division in Python

In this section, we shall program a simple Integer-Division Calculator in Python.

integer_division_program_quotient_included_final

Figure 3:  In the above-depicted program, we have programmed a simple Integer-Division Calculator that requests the user to input a dividend and a Divisor.  The Integer-Division Calculator then returns a quotient.

integer_division_program_output_final_quotient_included

Figure 4:  What the Integer-Division Calculator, as depicted in Figure 3, outputs when we, the user, input the Dividend, 8, and the Divisor, 4.  As we can see, the program outputs the quotient, 2.

Glossary

divide

  • verb.
  1. [with object] [MATHEMATICS] find how many times (a number) contains another: 36 divided by 2 equals 18.
  • [no object] (of a number) be susceptible of division without a remainder: 30 does not divide by 8.
  • find how many times (a number) is contained in another: divide 4 into 20.

<ORIGIN> Middle English (as a verb): from Latin divider ‘force apart, remove’.  the noun dates from the mid 17th century.[3]

<ETYMOLOGY>  From the Latin 3rd-conjugation verb, ‘dīvidō dividere, dīvīsī, dīvīsum,’ which means, ‘to divide;’ ‘to separate.’  From the Latin inseparable particle, ‘dĭs,’ or ‘dis-’ which means ‘in two;’ and the Latin 2nd-declension verb, ‘videō vidēre, vīdī, vīsum,’ which means ‘to see.’  The etymological sense of the preceding seems to be ‘to arrange something such that it appear in two.’

dividend

    1. a sum of money paid regularly (typically annually) by a company to its shareholders out of its profits (or reserves).
      • a payment divided among a number of people, e.g. winners in a football pool or members of a cooperative.
      • an individual’s share of a dividend.
      • (dividends) a benefit from an action or policy: buying a rail pass may still pay dividends.
    2. [MATHEMATICS] a number to be divided by another number.

<ORIGIN> late 15th century (in the general sense ‘portion, share’): from Anglo-Norman French dividend, from Latin dividendum ‘something to be divided’, from the verb divider (see DIVIDE).[4]

<ETYMOLOGY>  From the Latin gerundive, ‘dīvidendum est,’ which means ‘that which must be divided.’  From the Latin 3rd-conjugation verb, ‘dīvidō dividere, dīvīsī, dīvīsum,’ which means, ‘to divide;’ ‘to separate.’  From the Latin inseparable particle, ‘dĭs,’ or ‘dis-’ which means ‘in two;’ and the Latin 2nd-declension verb, ‘videō vidēre, vīdī, vīsum,’ which means ‘to see.’  The etymological sense of the preceding seems to be ‘to arrange something such that it appear in two.’

 

 

division

  • noun. [mass noun]
    1. the action of separating something into parts or the process of being separated: the division of the land into small fields | a gene that helps regulate cell division.
      • the distribution of something separated into parts: the division of his estates between the two branches of his family.
      • [count noun] an instance of members of a legislative body separating into two groups to vote: the new clause was areed without a division.
      • [LOGIC] the action of dividing a wider class into two or mor subclasses.
    2. the process of dividing one number by another.
      • [MATHEMATICS] the process of dividing a matrix, vector, or other quantity by another under specificrules to obtain a quotient.

 

<ORIGIN> late Middle English: fromOld French devisiun, from Latin divisio(n-), from the verb dividere (see DIVIDE).[5]

<ETYMOLOGY>  From the Latin 3rd-declension Feminine noun, ‘dīvīsiō, dīvīsiōnis,’ which means ‘a division,’ ‘a distribution.’

 

 

divisor

  • noun. [MATHEMATICS] a number by which another number is to be divided.
    • a number that divides into another without a remainder.

<ORIGIN>  late Middle English: from French diviseur or Latin divisor, from dividere (see DIVIDE).[6]

<ETYMOLOGY>  From the Latin 3rd-declension masculine noun, ‘dīvīsor, dīvīsōris,’ which means ‘one who distributes.’

 

 

 

equation

    1. [MATHEMATICS] a statement that the values of two mathematical expressions are equal (indicated by the sign =)
    2. [mass noun] the process of equating one thing with another: the equation of science with objectivity.
      • (the equation) a situation in which several factors must be taken into account: money also came into the equation.
    3. [CHEMISTRY] a symbolic representation of the changes which occur in a chemical reaction, expressed in terms of the formulae of the molecules or other species involved.

<PHRASES>

  • equation of the first (or second etc.) order [MATHEMATICS] an equation involving only the first derivative, second derivative, etc.

<ORIGIN> late Middle English: from Latin aequatio-(n-), from aequare ‘make equal’ (see EQUATE).[7]

<ETYMOLOGY> from the Latin 1st-and-2nd-declension adjective, ‘æqua, æquus, æquum,’ which means ‘equal;’ and the 3rd-declension nominal suffix, ‘-tiō, (-tiōnis),’ which denotes a state of being.  Therefore, etymologically, an ‘equation’ is ‘a state of being equal.’  Etymologically, therefore, an ‘equation’ is a mathematical statement that declares terms to be equal.


 

operator

  1. [MATHEMATICS] a symbol or function denoting an operation (e.g. ).[8]

<ETYMOLOGY>  From the 3rd-declension masculine Latin noun, ‘ŏpĕrātor, ŏpĕrātōris,’ which means ‘operator,’ ‘worker.’  The Latin 3rd-declension noun, ‘opus, operis,’ which means ‘work,’ ‘labour.’  From the Latin 1st-conjugation verb, ‘operō, operāre, operāvī, operātor;’ and the 3rd-declension nominal suffix, ‘-or,       (-ōris)’ which denotes a performer of an action.  Etymologically, as regards Mathematics, it is the operator that is said to perform the work of the operation.

operation

  • noun.
    • [mass noun] the action of functioning or the fact of being active or in effect: restrictions on the operation of market forces | the company’s first hotel is now in operation.
  1. [MATHEMATICS] a process in which a number, quantity, expression, etc., is altered or manipulated according to set formal rules, such as those of addition, multiplication, and differentiation.

<ORIGIN> late Middle English: via Old French from Latin operatio(n-), from the verb operari ‘expend labour on’ (see Operate)[9]

 

<ETYMOLOGY>  From the Latin 3rd-declension feminine noun, ‘ŏpĕrātĭo, ŏpĕrātĭōnis,’ which means ‘a working,’ ‘a work,’ ‘a labour,’ ‘operation.’  From the Latin 1st-declension deponent verb ‘operor, operāre, operātus sum,’ which means ‘to work,’ ‘to labour,’ ‘to expend labour on;’ and the Latin 3rd-declension nominal suffix, ‘-iō, (-iōnis),’ which denotes a state of being.  Etymologically, therefore, as regards Mathematics, an ‘operation’ is a ‘mathematical work;’ ‘mathematical working;’ a ‘mathematical labour.’  The mathematical work that would be carried out depends on the operator.  For instance, if the operator be a plus sign, then the mathematical work to be carried out would be addition.  Addition is a type of operation.

 

 

 

 

 

 


[1]  dīvīsiō ōnis, f

[VID-], a division, distribution…

Latin English Lexicon: Optimized for the Kindle, Thomas McCarthy, (Perilingua Language Tools: 2013) Version 2.1  Loc 32190

See GLOSSARY

[2]  See the chapter, TWO WAYS OF CONCEPTUALISING DIVISION https://mathsandcomedy.com/2016/06/29/one-way-of-conceptualising-division/

https://mathsandcomedy.com/2016/07/03/another-way-of-conceptualising-division/

[3] Oxford University Press. Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc 202778

[4]  ibid.  Loc 202820

[5]  Oxford University Press. Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc 202998

[6] ibid. Loc 203079

[7]  ibid.  Loc 234861

[8]  ibid.  Loc 493860.

[9] ibid.  Loc 493797

The Concatenation of Strings and Variables in Python.

(Click the below link for a Microsoft Word version of this blog-post)

the_concatenation_of_strings_and_variables

(Click the below link for a pdf version of this blog-post)

the_concatenation_of_strings_and_variables

Usually., when I need to concatenate[1] strings and non-string variables, I employ the:

+

sign and the:

str()

method to do so.

concatenation_str_method_program

Figure 1:  In the above program, we use the plus sign and the str() method so as to concatenate the integer variables, x and y, to a string contained within a print() statement.

concatenation_str_method_program_output

Figure 2:  What the program depicted in Figure 1 outputs.

However, it is also possible to concatenate strings and non-string variables by simply using a comma:

concatenation_comma_program

Figure 3:  In this example, we simply use a comma to concatenate the string,         “x = ” with the integer variable, x; and the string, “y = ” with the integer variable, y.

concatenation_comma_program_output

Figure 4:  What the program depicted in Figure 3 outputs.    Note that this program’s output is identical to what the program depicted in Figure 1 outputs.


[1]  See chapter on CONCATENATION.

Integers in Python:

(Click the below link for a Microsoft Word version of this blog-post)

what_is_an_integer

(Click the below link for a pdf version of this blog-post)

what_is_an_integer

What is an Integer?

In Mathematics:

An integer is a number that has no fractional[1] component.  The term ‘integer’ in Latin means ‘whole.’  So an Integer is a Whole Number[2].  A person who practises wholesome behaviour is a person with integrity.

In Number Theory, the set of integers is very often represented by a boldface Capital ‘Z’[3]:

Z

Sometimes, in Number Theory, the set of integers is represented by a blackboard bold ‘Z’:

  \mathbb {Z}

The set of integers comprises:

  • the number:

0

  • the sequence of positive Natural Numbers:

{1, 2, 3, 4, 5…}

  • the sequence of negative integers:

{-1, -2, -3, -4, -5…}

In Python:

In Python, integers are a datatype.  This datatype is assigned the keyword:

int

int_key_word

Figure 1:  In Python, the int keyword represents the integer datatype.

In Python, we can use the:

int()

method so as to convert numbers that might exist as strings, or other datatypes, to integers:

type_conversion_string_to_int

Figure 2:  In the above example, we convert the number, 3, from a Python string to a Python integer by using the int() method.  This is called ‘type conversion.’

type_conversion_float_to_int

Figure 3:  In the above example, we convert the number, 3.0, from a Python float to a Python integer by using the int() method.  This is called ‘type conversion.’

Glossary:

integer

  • noun.
    1. a number which is not a fraction; a whole number.
    2. a thing complete in itself.

<ORIGIN early 16th century (as an adjective meaning ‘entire, whole’): from Latin, ‘intact, whole’, from in(expressing negation) + the root of tangere ‘to touch’.  Compare with ENTIRE, also with Integral, integrate, and INTEGRITY[4].

<ETYMOLOGY> From the Latin 1st-and-2nd-declension adjective, ‘integra, integer, integrum,’ which means ‘complete,’ ‘whole,’ ‘intact.’  From the Latin prefix ‘in-,’ which expresses negation; and the Latin verb ‘tangō, tangere, tetigī, tāctum,’ which means ‘to touch.’  Etymologically, therefore, an ‘integer’ is a number that is ‘intact’ i.e. which does not have a fractional component.

 

 

 

 

 


[1]  Whereas ‘integer’ comes from the Latin word for ‘whole,’ ‘fraction’ comes from the Latin supine ‘frāctum,’ which means ‘broken.’  The term ‘fraction’ is derived from the Latin 3rd-conjugation verb, frangō, frangere, frēgī, frāctum,’ which means ‘to break,’ ‘to shatter.’  If something be fragile, then it is easily broken; it is liable to shatter.  A fraction, etymologically, is like a broken-off piece of a number.

[2]  I speak, here, in general parlance.  Mathematically, some would argue a difference between whole numbers and integers.  Mathematicians sometimes regard whole numbers as comprising the sequence of positive integers: {0, 1, 2, 3, 4, 5…}.  I am merely trying to get across the concept that an Integer has no fractional part.

[3]  The ‘Z’ represents the plural of the German feminine noun, ‘die Zahl,’ ‘the number,’ which is ‘die Zahlen.’

[4]  Oxford University Press. Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc 357261

The Mathematical Distinction that Exists between Precision and Accuracy.

Click the below link so as to view a Microsoft-Word version of this blog post.

the_mathematical_distinction_that_exists_between_precision_and_accuracy.docx

Click the below link so as to view a pdf version of this blog post.

the_mathematical_distinction_that_exists_between_precision_and_accuracy.pdf

 

The Mathematical Distinction that exists between Precision and Accuracy:

Introduction:

In everyday common parlance, the terms ‘precision’ and ‘accuracy’ are synonyms. However, this is not so in Mathematical jargon. In mathematical jargon, there exists an important difference in meaning between the terms ‘precision’ and ‘accuracy.’ It is the purpose of this chapter to explicate this difference in meaning.

Body:

If one should derive:

π

to eleven decimal places by dividing 22 by 7:

22/7

, then the result of this calculation:

3.14285714286

will be more precise than:

π

derived properly – i.e. through differentiation – to eight decimal places:

3.14159265

, but the latter answer will be more accurate than the former.

In mathematics, the term, ‘precision,’ denotes how many decimal places the result of a calculation can run to[1], whereas the term, ‘accuracy,’ denotes how close to the correct answer the result of a calculation is.

In mathematics, the term, ‘precision’ denotes how many significant digits that a mathematician should use to render a quantity, whereas the term ‘accuracy’ denotes how close to the correct quantity the quantity rendered in digits is.

An Etymological Definition:

The English term, ‘precision’ comes from the Latin 3rd-declension feminine noun, ‘praecīsiō, praecīsiōnis,’ which means a ‘cutting off[2] .’ After how many significant digits ought we to cut the answer off?

The verb, ‘caedere,’ can also mean ‘to kill[3] .’ After how many significant digits do we kill off the trail?

After our dividing 22 by 7:

22/7

, we cut the answer off after 11 significant digits following the decimal point:

3.14285714286

.
We use a total of 12 significant digits in our rendering of:

π

.

After arriving at:

π

, properly – i.e. through differentiation – we cut the answer off after 8 significant digits following the decimal point:

3.14159265

.

We use a total of 9 significant digits in our rendering of:

π

.

In the first case, we employ 12 significant digits in our rendering of:

π

, and, in the latter case, we employ 9 significant digits in our rendering of:

π

. Therefore, again, to restate, the former rendering of:

π

is more precise than the latter, however, the latter rendering of:

π

is more accurate than the former.

Precision in Python:

It is possible to modify the precision of π, in Python, by applying formatting[4]

python_pi_precision_program_code

Figure 1:  We have, here, created a program that prints out π with varying degrees of precision; from the most precise: with 6 significant figures trailing the decimal point; to the least precise: with 0 significant figures trailing the decimal point.

python_pi_precision_program_output

Figure 2:  What the previous Python script outputs.

Epilogue: What is π?

pi_pen

Figure 3:  The iconic symbol.  π is the sixteenth letter of the Ancient-Greek Alphabet.  This is its minuscule form.  It is conjectured that the Ancient-Greek letter, π, was employed so as to represent the length of a circle’s circumference, as the letter, ‘pi’ can be taken as a contraction of the term, ‘perimeter.’

π comes into play with the radians of Trigonometry, a crucial component of Computing Mathematics, so we may as well digress a little and ask ourselves what π actually is.

 

π symbolises and denotes the ratio that exists between the length of a circle’s diameter and the length of a circle’s circumference.

pi_ratio_diagram

 

Figure 4:  π is equal to the ratio that exists between the length of a circle’s diameter, and the length of a circle’s circumference.

The ratio:

Diameter : Circumference

can be expressed as the ratio:

1 : 3.14159…

Glossary:

accuracy

  • noun.

(plural. accuracies)

     [mass noun] the quality or state of being correct or precise:  we have confidence in the accuracy of the statistics.

 

  • TECHNICAL the degree to which the result of a measurement, calculation, or specification conforms to the correct value or standard: the accuracy of radiocarbon dating | [count noun] accuracies of 50-70 per cent. Compare with PRECISION. [1]

<ETYMOLOGY>  From the Latin 3rd-declension Latin noun, ‘accurātiō, accurātiōnis,’ which means ‘accuracy,’ ‘carefulness.’  From the Latin preposition, ‘ad,’ which means ‘towards;’ and the Latin 1st-declension feminine noun, ‘cūra, cūrae,’ which means ‘care;’ and the Latin 3rd-declension nominal suffix, ‘-ātiō’ which denotes a state of being.  The etymological sense of the English term, ‘accuracy,’ therefore, is ‘the state of being oriented towards carefulness.’

 

 

accurate

  • adjective.
  1. (especially of information, measurements, or predictions) correct in all details; exact: accurate information about the illness is essential.
    • (of an instrument or method) capable of giving accurate information: an accurate thermometer.
    • providing a faithful representation of someone or something: the portrait is an accurate likeness of Mozart.
  2. (with reference to a weapon, missile, or shot) capable of or successful in reachingthe intended target: reliable, accurate rifles | a player who can deliver long accurate passes to the wingers.

<DERIVATIVES> late 16th century: from Latin accuratus ‘done with care’, past participle of accurare, from ad- ‘towards’ + cura ‘care’.[2]

 

<ETYMOLOGY>  From the Latin 1st-conjugation verb, ‘accūrō, accūrāre, accūrāvī, accūrātum,’ or ‘adcūrō, adcūrāre, adcūrāvī, adcūrātum,’ which means ‘to give close attention to,’ ‘to be careful.’[3]

From the Latin preposition, ‘ad,’ which means ‘towards,’ and the Latin 1st-declension feminine noun, ‘cūra, cūrae,’ which means ‘care.’

precise

  • adjective.

marked by exactness and accuracy of expression or detail: precise directions | I want as precise a time of death as I can get.

  • (of a person) exact, accurate, and careful about details: the director was precise with his camera positions.
  • [attributive] used to emphasize that one is referring to an exact and particular thing: at that precise moment the car stopped.

<DERIVATIVES> preciseness noun.

<ORIGIN> late Middle English: from Old French precis, from Latin praecis- ‘cut short’, from the verb praecidere, from prae ‘in advance’ + caedere ‘to cut’[4].

 

<ETYMOLOGY> From the Latin 1st-and-2nd-declension adjective, ‘praecīsa, praecīsus, praecīsum,’ which means ‘broken off,’ ‘abrupt.’  From the Latin verb, ‘praecīdō, praecīdere, praecīdī, praecīsus,’ which means ‘to cut off in front,’ ‘cut off.’[5]

From the Latin preposition, ‘prae,’ which means ‘before,’ ‘beforehand;’ and the Latin 3rd-conjugation verb, ‘caedō, caedere, cecīdī, caesum,’ which means ‘to cut.’  The etymological sense of ‘precise’ – like ‘concise’ – is ‘cut off.’

 

 

precisely

in exact terms; without vagueness: the guidelines are precisely defined.

  • exactly (used to emphasize the complete accuracy or truth of a statement): at 2.00 precisely, the phone rang | kids will love it precisely because it will irritate their parents.
  • used as a reply to confirm or agree with a previous statements: ‘You mean it was a conspiracy?’ ‘Precisely.’ .[6]

 

precisian

chiefly ARCHAIC a person who is rigidly precise or punctilious, especially as regards religious rules.

<DERIVATIVES> precisianism noun.[7]

precision

  • [mass noun]

the quality, condition, or fact of being exact and accurate: the deal was planned and executed with military precision.

  • [as modifier] marked by or adapted for accuracy and exactness: a precision instrument.
  • TECHNICAL refinement in a measurement, calculation, or specification, especially as represented by the number of digits given: a technique which examines and identifies each character with the highest level of precision | [count noun] a precision of six decimal figures.

Compare with ACCURACY.

<ORIGIN> mid 18th century: from French precision or Latin praecīsiō(n-), from praecīdere ‘cut off’ (see PRECISE).[8]

<ETYMOLOGY>  From the Latn 3rd-declension feminine noun, ‘praecīsĭo, praecīsĭōnis,’ which means ‘a cutting off,’ ‘the piece cut off.’  In rhetoric, ‘praecīsĭo,’ means ‘a breaking off abruptly.’  In Late Latin, ‘praecīsĭo,’ can mean ‘an overreaching.’ [9]


 

radian

[GEOMETRY] a unit of measurement of angles equal to about 57.3°, equivalent to the angle subtended at the centre of a circle by an arc equal in length to the radius.[10]

<ETYMOLOGY>  From the Scientific Latin 1st-and-2nd-declension adjective, ‘radiāna, radiānus, radiānum’ which means ‘of the radius,’ ‘concerning the radius,’ ‘denoting the radius.’  From the Latin 2nd-declension masculine noun, ‘radius, radiī’ which means ‘a geometer’s rod[11] [for measuring the distance between the centre of a circle and the circumference],’ and the Latin 1st-and-2nd-declension adjectival suffix,      ‘-iāna, -iānus, -iānum,’ which means ‘of,’ ‘concerning,’ ‘denoting.’  The etymological sense of the English noun ‘radian’ is ‘that unit of measurement of angles that concerns radiuses.’

 

 

[1]  Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc 4388.

 

[2]  Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc 4388.

[3] Perlingua Language Tools.  www.perlingua.com   Version 2.1 (Kindle Edition.)  2013.  Latin English Lexicon.  Thomas Mc Carthy.  Loc. 1075.

[4] Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc. 554162.

[5] Perlingua Language Tools.  www.perlingua.com   Version 2.1 (Kindle Edition.)  2013.  Latin English Lexicon.  Thomas Mc Carthy.  Loc. 76264.

 

[6] ibid.  Loc. 554172

[7] ibid.  Loc. 554179

[8]  ibid.  Loc. 554191

[9]  Perlingua Language Tools.  www.perlingua.com   Version 2.1 (Kindle Edition.)  2013.  Latin English Lexicon.  Thomas Mc Carthy.  Loc. 76264.

[10]  Oxford University Press.  Oxford Dictionary of English (Electronic Edition). Oxford. 2010.  Loc. 578311.

[11]  Perlingua Language Tools.  www.perlingua.com   Version 2.1 (Kindle Edition.)  2013.  Latin English Lexicon.  Thomas Mc Carthy.  Loc. 87154.

 


[1]

See the Oxford Dictionary of English’s TECHNICAL definition of ‘precision’ in the glossary below.

[2]

From the Latin preposition ‘prae,’ which means ‘before,’ and the Latin 3rd-conjugation verb, ‘caedō, caedere, cecīdī, caesum,’ which means ‘to cut.’

[3]

For instance, a ‘suicide’ is a man or woman who kills himself/herself. From the Latin 1st-and-2nd-declension possessive adjective, ‘sua, suus, suum,’ which means ‘his, her, its;’ and the Latin 3rd-conjugation verb, ‘caedō, caedere, cecīdī, caesum,’ which means ‘to kill.’ The etymological sense of ‘suicide,’ therefore is a man or woman who kills himself/herself.

[4]

See the blogpost: Formatting Numbers in Python.

Python Dictionary:


I drew the snooker table and dart-board myself using Microsoft Paint.  With the dart-board, I hard-coded some concentric circles into the SVG editor, Brackets, and, thereafter, played about with it in Inkscape and Microsoft Paint.  Below is a link to a pdf version of the following web-post:

Python Dictionary



 Figure 1: In this chapter, we are going to use a snooker table, and a dart board, so as to come to grips with dictionaries.

When commencing the science known as computer programming, it is soon discovered that a lot of the skills, that must be learned, so as to become competent in this profession, has to do with ordering data.

We have already seen two other ways that we may order data, i.e. lists and tuples1.

What concerns us now is dictionaries.

Dictionaries are Python-specific, which means that they do not really exist in other programming languages.

Python Dictionaries have been compared with Associative Arrays2 in other programming languages, though.

In Python, a Dictionary is an unordered Database of sorts. In a dictionary, each datum has a unique numeric key associated with it.

It is not possible, in dictionaries, to assign two pieces of data to the same numeric key. This is a rule consistent with most databases. Indeed, the definition of a ‘database’ is a table of data, where each row of the table is assigned a unique numeric key. If one were to assign to two rows of a table of data the same numeric key, then that table of data would then cease, by that very deed, to be a database.

In a Python dictionary, we assign each datum a unique numeric value, or key. Hence, in Python, a dictionary is a type of database.

In a dictionary, the numeric values that we assign to objects must be unique. The numeric values need not be in numeric order. One could have a dictionary containing merely two pieces of data, one having a numeric key of 1, and the other having a numeric key of 60:


Figure 2: Apart from darts that miss the dartboard completely – humorously termed ‘masonry darts’ – or darts that ricochet off the metal stripes, the minimum score from one throw is 1. The maximum score from one throw is 60. Below, we contrive a dictionary so as to represent this data.

>>>dart_scores_on_one_throw = {“Minimum Score”:1, “Maximum Score”:60}

>>> print(dart_scores_on_one_throw)

{‘Maximum Score’: 60, ‘Minimum Score’: 1,}


Figure 3: We have created our first dictionary. See how, when we ask it to print out our dictionary, it does not output the data in the same way that we inputted it, i.e. in numeric order. Remember: a dictionary is an unordered assortment of data.

We are going to create another dictionary.  This dictionary will be a little more complex, in that it will concern the values of balls on a snooker table:

(Preceding Page) Figure 4: The values of balls on a snooker table. We are going to create a dictionary in Python so as to express the above information.

>>>snooker_dictionary = {“Red”:1, “Yellow”:2, “Green”:3, “Brown”:4, “Blue”:5, “Pink”:6, “Black”:7}

>>>print(snooker_dictionary)

{‘Red’: 1, ‘Yellow’: 2, ‘Green’: 3, ‘Brown’: 4, ‘Blue’: 5, ‘Pink’: 6, ‘Black’: 7}


Figure 5: Above is the Python code that we use to create our Python Dictionary.

We employ:

snooker_dictionary

as our dictionary’s variable name. We then assign to that variable, the dictionary value:

{“Red”:1, “Yellow”:2, “Green”:3, “Brown”:4, “Blue”:5, “Pink”:6, “Black”:7}

by using the assignment/assignation operator:

=

.

We ask Python to print the snooker dictionary:

print(snooker_dictionary)

and Python outputs:

{‘Red’: 1, ‘Pink’: 6, ‘Black’: 7, ‘Green’: 3, ‘Yellow’: 2, ‘Blue’: 5, ‘Brown’: 4}

 


Figure 5: The code necessary to create a dictionary and its output. Note how Python outputs the dictionary neither how we entered it; neither in alphabetical order; neither in numerical order. Again, a dictionary is an unordered database of sorts.

It is possible for us, once a dictionary has been created, to split a dictionary up into separate values. We can do this through the following code:

>>>snooker_dictionary = {“Red”:1, “Yellow”:2, “Green”:3, “Brown”: 4, “Pink”:6, “Black”:7}↵

    >>>print(snooker_dictionary)

    {‘Blue’: 5, ‘Red’: 1, ‘Yellow’: 2, ‘Brown’: 4, ‘Pink’: 6, ‘Green’: 3, ‘Black’: 7}

>>>for a in snooker_dictionary:
print(a, snooker_dictionary[a])

    Blue 5

Red 1

Yellow 2

Brown 4

Pink 6

Green 3

Black 7

Figure 6: What the above code looks like in a Python Interactive window.

A dictionary is a value in and of itself. This value, we assigned to the variable:

snooker_dictionary

.

By executing the above code, we have extracted the component values of the dictionary value.

There is another useful thing that we can do to dictionaries: we can append new terms to it.

In anatomy, appendages, such as arms and legs, are those organs that hang on to the trunk, or core.

The term ‘to append,’ etymologically, means ‘to hang [something] on to [something.]’

present active:pendō,’ ‎present infinitive: ‘pendere,’ perfect active: ‘pependī,’ supine: ‘pensum‘; third conjugation.

is the Latin verb, ‘to hang.’

‘ad’

is the Latin preposition that means:

‘to, toward.’

Affix the preposition, ‘ad,’ to the verb, ‘pendō,‘ and we get ‘appendō,’ which is the Latin verb, ‘to hang [something] towards [something else.]’

In Python, we can append or hang another [component value] on to our dictionary.

We are able to change dictionaries. This means that dictionaries, in programing jargon, are mutable3.

Let us return to our:

snooker_dictionary

and let us imagine a rule change, the addition of a purple ball of value: 8.

    Figure 7: The purple ball. Just imagine the possibilities!

(From Preceding Page) Figure 8: We shall position the purple ball just above the blue, I think.

The rules of snooker have been changed, which necessitates a change in the value
of our:

snooker_dictionary

variable. Luckily, dictionaries are mutable, and it will not be difficult for us to amend our dictionary so as to reflect the addition of a purple ball into the game of snooker:

>>> snooker_dictionary = {“Red”:1, “Yellow”:2, “Green”:3, “Brown”:4, “Blue”:5, “Pink”: 6, “Black”: 7}

>>> print(snooker_dictionary)

{‘Yellow’: 2, ‘Green’: 3, ‘Brown’: 4, ‘Black’: 7, ‘Red’: 1, ‘Pink’: 6, ‘Blue’: 5}↵

>>> snooker_dictionary[‘Purple’] = 8↵

>>> print(snooker_dictionary)↵

{‘Yellow’: 2, ‘Green’: 3, ‘Purple’: 8, ‘Brown’: 4, ‘Black’: 7, ‘Red’: 1, ‘Pink’: 6, ‘Blue’: 5}

>>>

From the above code, we can garner that it is the:

snooker_dictionary[‘Purple’] = 8

piece of code that appends the value:

‘Purple’: 8

to our pre-existing dictionary.

Figure 8: What the code looks like executed in a Python Interactive Window.

In Conclusion:

In this chapter we have examined what a dictionary is – a type of unordered database; created a dictionary; extracted component values from a dictionary; and we have also appended new information to a dictionary. For a beginner programmer, such as yourself, the reader, this is all you will be required to know of this topic at the moment.

Dictionaries are a kind of an array, which means that a Dictionary can be a sub-element in another dictionary; a super-dictionary. We do not need to examine multidimensional dictionaries yet, though.


1Please see the relevant chapters on LISTS and TUPLES.

2Please see the relevant chapter on ARRAYS.

3From the Latin 1st-conjugation verb, ‘mūtō, mūtāre, mūtāvī, mūtātus,’ which means ‘to change,’ and the Latin 3rd-declension adjective, ‘habilis, habile,’ which means ‘having,’ whence we derive the Latin adjective-making suffix, ‘-abilis, -abile.’ Combine the Latin verb, ‘mūtō,’ with the suffix, ‘-abilis, -abile’ and we get the 3rd-declension Latin adjective, ‘mūtābilis, mūtābile,’ which denotes something that has [the ability] to change. In Python Programming, dictionaries have the ability to change.

I Have 7 Cats: Formatting Numbers in Python


Link To Pdf:

Below is a Link to a pdf version of this web post:

Formatting Numbers in Python


 

Formatting Numbers in Python.

Figure 1: I have 7 cats.

The table below shows us different ways that we may format a number in Python. In this instance, I have chosen the number, 7.

Syntax:

Output:

print(“I have {0:d} cats”.format(7,6,5,4)) I have 7 cats
print(“I have {0:3d} cats”.format(7,6,5,4)) I have 7 cats
print(“I have {0:03d} cats”.format(7,6,5,4)) I have 007 cats
print(“I have {0:f} cats”.format(7,6,5,4)) I have 7.000000 cats
print(“I have {0:.2f} cats”.format(7,6,5,4)) I have 7.00 cats

I will take every entry of the above table, individually, and shall explain what is going on.

  1. print (“I have {0:d} cats”.format(7,6,5,4))


    Figure 2: The contents of the chain parenthesis analysed.

In the above command, we specify, to python, that we wish to format the zeroth1 number-element in the listed sequence:

(7,6,5,4)

.

This is what the:

0

part of:

{0:d}

is for.

In this instance the zeroth number-element in the listed sequence is:

7

.

Therefore, it will be the number, 7, that will be formatted and printed by Python.

We use a

d

in the chain parenthesis, to let Python know that we wish to format the number:

7

as an ordinary decimal number.

When we give the command:

>>> print(“I have {0:d} cats”.format(7,6,5,4))

to Python, Python outputs:

I have 7 cats

.

Below are examples of what occurs when we give formatting commands such as these to a Python Interactive Window:


Figure 3: In the above example, we, systematically, format all of the number-elements in the sequence: (7,6,5,4). We do this by altering the value of the number before the colon in the chain parenthesis.

  1. print (“I have {0:3d} cats”.format(7,6,5,4))


Figure 4: The contents of the chain parenthesis analysed.

In the above command, we specify, to python, that we wish to format the zeroth number-element in the listed sequence:

(7,6,5,4)

.

This is what the

0

part of:

{0:3d}

is for.

In this instance the zeroth number-element in the listed sequence is:

7

.

Therefore, it will be the number, 7, that will be formatted and printed by Python.

We use a

d

in the chain parenthesis, to let Python know that we wish to format the number:

7

as an ordinary decimal number.

The

3

character tells python that we wish the decimal number, i.e. 7, to be the third character after leading2 characters. As we do not specify what form that we wish for these leading characters to take, then:

7

will be the third character after two leading spaces.

When we give the command:

>>> print(“I have {0:3d} cats”.format(7,6,5,4))

to Python, Python outputs:

I have 7 cats

.

Below are examples of what occurs when we give formatting commands such as these to a Python Interactive Window:


Figure 5: In the above example, we, systematically, format all of the number-elements in the sequence: (7,6,5,4). We do this by altering the value of the number before the colon in the chain parenthesis.

  1. print (“I have {0:03d} cats”.format(7,6,5,4))


Figure 6: The contents of the chain parenthesis analysed.

In the above command, we specify, to python, that we wish to format the zeroth number-element in the listed sequence:

(7,6,5,4)

.

This is what the

0

part of:

{0:03d}

is for.

In this instance the zeroth number-element in the listed sequence is:

7

.

Therefore, it will be the number, 7, that will be formatted and printed by Python.

We use a

d

in the chain parenthesis, to let Python know that we wish to format the number:

7

as an ordinary decimal number.

The

3

character tells python that we wish the decimal number, i.e. 7, to be the third character after leading characters3.

The:

0

prior to the:

3

and following the:

:

in:

{0:03d}

signifies the leading character:

zero

.

Therefore:

7

will be the third character after two leading zeros.

When we give the command:

>>> print(“I have {0:03d} cats”.format(7,6,5,4))

to Python, Python outputs:

I have 007 cats

.

Below are examples of what occurs when we give formatting commands such as these to a Python Interactive Window:


Figure 7: In the above example, we, systematically, format all of the number-elements in the sequence: (7,6,5,4). We do this by altering the value of the number before the colon in the chain parenthesis.

  1. print (“I have {0:f} cats”.format(7,6,5,4))


Figure 8: The contents of the chain parenthesis analysed.

In the above command, we specify, to python, that we wish to format the zeroth number-element in the listed sequence:

(7,6,5,4)

.

This is what the

0

part of:

{0:f}

is for.

In this instance the zeroth number-element in the listed sequence is:

7

.

Therefore, it will be the number, 7, that will be formatted and printed by Python.

We use an:

f

in the chain parenthesis, to let Python know that we wish to format the number:

7

as a floating-point number4.

When we give the command:

>>> print(“I have {0:f} cats”.format(7,6,5,4))

to Python, Python outputs:

I have 7.000000 cats

.

As we can see, the number,

7,

its being a float is followed by a decimal point and six trailing zeros.

Below are examples of what occurs when we give formatting commands such as these to a Python Interactive Window:


Figure 9: In the above example, we, systematically, format all of the number-elements in the sequence: (7,6,5,4). We do this by altering the value of the number before the colon in the chain parenthesis.

  1. print (“I have {0:.2f} cats”.format(7,6,5,4))


Figure 10: The contents of the chain parenthesis analysed.

In the above command, we specify, to python, that we wish to format the zeroth number-element in the listed sequence:

(7,6,5,4)

.

This is what the

0

part of:

{0:.2f}

is for.

In this instance the zeroth number-element in the listed sequence is:

7

.

Therefore, it will be the number, 7, that will be formatted and printed by Python.

We use a

f

in the chain parenthesis, to let Python know that we wish to format the number:

7

as a float.

The

.2

characters tell python that we wish the floating-point number, i.e. 7, to be followed, after a decimal point, by two trailing characters, in this instance, zeros.

When we give the command:

>>> print(“I have {0:.2f} cats”.format(7,6,5,4))

to Python, Python outputs:

I have 7.00 cats

.

As we can see, from the above example, the number:

7

, is now followed by a decimal point and two trailing zeros, as per our command.

Below are examples of what occurs when we give formatting commands such as these to a Python Interactive Window:


Figure 11: In the above example, we, systematically, format all of the number-elements in the sequence: (7,6,5,4). We do this by altering the value of the number before the colon in the chain parenthesis.


Figure 12: In this instance, the characters that trail after the decimal point are significant, i.e. not zero. Python rounds up 7.76543 to 7.77.


1 In programing, it is conventional to begin counting beginning at 0, not beginning at 1. Therefore, zeroth, or 0th, is an ordinal number. Hence: Zeroth, First, second … Hence: 0th, 1st, 2nd …

2 In Mathematics, the two zeros that precede the number, 7, in a number such as: 007 , are termed ‘leading zeros.’ In Mathematics, the two zeros that follow a number such as: 0.700 , are termed ‘trailing zeros.’

3 In Mathematics, the two zeros that precede the number, 7, in a number such as: 007 , are termed ‘leading zeros.’ In Mathematics, the two zeros that follow a number such as: 0.700 , are termed ‘trailing zeros.’

4 In programming, this is generally termed: ‘float.’