Structuring Python Programs

Python is very flexible about building a program. Instructions do not require specific performance that works in the module or classroom or classroom method.

                                                          Introduction to Python 3

Table of Content:

1) Python Statement
2) Line Continuation 
        --> Implicit Line Continuation
        --> Explicit Line Continuation
3) Multiple Statement Per Line 
4) Comments
5) WhiteSpace
6) Whitespace as Indentation
7) Conclusion

Python Statement

Tell them that the Python interpreter is a basic unit of learning and methods. In general, the interpreter performs the following instructions, each one, when they meet. (You will see a description of the following conditions that may be possible to change the behavior.)
Most examples of the series in this series are followed by this method:

>>> print('Hello, World!')
Hello, World!
>>> x = [1, 2, 3]
>>> print(x[1:2])
[2]

Line Continuation


Suppose a single statement in your Python code is especially long. For example, you may have an assignment statement with many terms:
>>> person1_age = 42
>>> person2_age = 16
>>> person3_age = 71
>>> someone_is_of_working_age = (person1_age >= 18 and person1_age <= 65) or (person2_age >= 18 and person2_age <= 65) or (person3_age >= 18 and person3_age <= 65)
>>> someone_is_of_working_age
True

Implicit Line Continuation

Think of a single sentence in the Python code, especially for a long time. For example, you may have a lot of contact with many jobs:

>>> a = [
... [1, 2, 3, 4, 5],
... [6, 7, 8, 9, 10],
... [11, 12, 13, 14, 15],
... [16, 17, 18, 19, 20],
... [21, 22, 23, 24, 25]
... ]
>>> a
[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15],
[16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]
This technique is easier to maintain, and the preferred option as described in pep 8.
For example, the list of the above listings can be readable using an indirect line because of the words:

Explicit Line Continuation


>>> s =
File "<stdin>", line 1
s =
^
SyntaxError: invalid syntax
>>> x = 1 + 2 +
File "<stdin>", line 1
x = 1 + 2 +
^
SyntaxError: invalid syntax
In the case of an indirect line that is not available or feasible, there is no other option. This is called regular routes such as a straight line or white organization.
Generally, a new line of character (which lets you put pressure on the keyboard) shows the end of the line. If the statement is incomplete, Python will throw SyntaxError except:

Multiple Statement Per Line

Some states may fall in line if they distinguish between dangerous behaviors (;):

>>> x = 1; y = 2; z = 3
>>> print(x); print(y); print(z)
1
2
3

Comment

In Python, marijuana (#) shows a comment. The interpreter will ignore everything, from the letters of smoke to the end of the line:

>>> a = ['foo', 'bar', 'baz'] # I am a comment.
>>> a
['foo', 'bar', 'baz']

WhiteSpace

When checking the code, the Python interpreter breaks into the product. In non-standard lights, the languages are the language we only see so far: the identification, keywords, literature, and operators.
Generally, some of the other features have a clear, vacant open space to improve reading. The places are more than the following:

CharacterASCII CodeLiteral Expression
space32 (0x20)' '
tab9 (0x9)'\t'
newline10 (0xa)'\n'

Whitespace as Indentation

There is an important position in the clear position that is important for the Python code. outdoor space, appearing on the left side of the line signal - the specific meaning.
In most cases, open spaces before learning are ignored. For example, consider the Windows control panel:

C:\Users\john>echo foo
foo
C:\Users\john> echo foo
foo

Conclusion

This lesson has been presented by the Python program. You are learning what is the exact word of Python and how to use a direct and indirect line to write the proof, including a number of lines. You can also learn more about Python's comments, and use of a clear position to enhance reading.
In addition, you will learn how a group statement of decision making uses many complex and complex terms.

To getting expect level training for Python training in your Location – Python training in Chennai | Python training institute in Chennai | Python Course institute in Chennai | Python training in Bangalore | Python training institute in Bangalore Python training in Electronic City Python training in Jaya Nagar | Python training in Pune | Python training institute in Pune | Python training in OMR | Python training in Velachery | Python training in Tambaram Python training in Annanagar | Python training in Marathahalli Python training in btm | Python Online Training | Online Certification Course Python Course in Chennai Python interview questions and answers | Python tutorials | Python training in Indira Nagar | Python Course in btm | Python Course in Marathahalli 


Comments

Post a Comment

Popular posts from this blog

Python – Functions

What is Django in python?

Python Shallow Copy and Deep Copy