Python: 3 Books in 1: Machine Learning, Python and Data Science. Learn Computer Programming for Beginners. by Oliver Soranson

Python: 3 Books in 1: Machine Learning, Python and Data Science. Learn Computer Programming for Beginners. by Oliver Soranson

Author:Oliver Soranson [Soranson, Oliver]
Language: eng
Format: epub
Published: 2020-05-07T17:00:00+00:00


If the sun does not come out, then I will not perform any of these functions.

In most other programming languages, the developer will group all three statements into one block, and, if the first condition returns true, then the program will execute all three statements in the block. If it returns false, however, none will execute.

Python, on the other hand, follows the offside rule, which is all about indentation. Peter J Landin, a computer scientist from Britain, coined this term taken from the offside law in soccer. The relatively few machine languages that follow this rule define these compound statements or blocks using indentation.

In Python, indentation plays an important function, in addition to defining blocks. Python considers contiguous statements indented to the same level to constitute the same compound statement. Therefore, the program executes the whole block if the statement returns true, or skips it if false. In Python, a suite is a group of statements with the same level of indentation level.

Most other machine languages, on the other hand, use unique tokens to identify the beginning and end of a block, while others use keywords. Beauty, however, is in the eye of the beholder. On the one hand, the use of indentation by Python is consistent, concise, and clean.

On the other hand, in machine languages that do not adhere to the offside rule, code indentation is independent of code function and block definition. Therefore, developers can write indent their code in a way that does not match how it executes, which can create a wrong impression when someone looks at it. In Python, this type of mistake cannot happen. The use of indentation to define compound statements forces developers to remain true to their standards of formatting code.

Sometimes, while evaluating a certain condition, developers might want to perform a certain function if the condition is true, and perform an alternative function if it turns out to be false. This is where the 'else' clause comes in. for example:

if <expr>:

<statement/statements>

else:

<statement/statements>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.