Basic Python 6: Statement, Indentation and Comments

Veröffentlicht am: 13 September 2022
auf dem Kanal: Testing Tutorialspoint
172
6

Statement, Indentation and Comments:
-----------------------------------
Statement:
----------
Python interpreter can execute are called statements. For example, a = 1 is an assignment statement. if statement, for statement, while statement, etc.

Multi-line statement:

the end of a statement is marked by a newline character. But we can make a statement extend over multiple lines with the line continuation character (\).
ex:
a = 1 + 2 + 3 + \
4 + 5 + 6 + \
7 + 8 + 9

line continuation is implied inside parentheses ( ), brackets [ ], and braces { }.
ex:
a = (1 + 2 + 3 +
4 + 5 + 6 +
7 + 8 + 9)

Indentation:
------------
Most of the programming languages like C, C++, and Java use braces { } to define a block of code. Python, however, uses indentation.

A code block (body of a function, loop, etc.) starts with indentation and ends with the first unindented line. The amount of indentation is up to you, but it must be consistent throughout that block.
ex:
for i in range(1,11):
print(i)
if i == 5:
break

Comments:
---------
Comments are very important while writing a program. They describe what is going on inside a program, so that a person looking at the source code does not have a hard time figuring it out.

we use the hash (#) symbol to start writing a comment.

Multi-line comments
We can have comments that extend up to multiple lines. One way is to use the hash(#) symbol at the beginning of each line.

Another way of doing this is to use triple quotes, either ''' or """.

These triple quotes are generally used for multi-line strings. But they can be used as a multi-line comment as well. Unless they are not docstrings, they do not generate any extra code.
ex:
"""This is also a
perfect example of
multi-line comments"""

Docstrings in Python:
---------------------
A docstring is short for documentation string.

Python docstrings (documentation strings) are the string literals that appear right after the definition of a function, method, class, or module.
ex:
def double(num):
"""Function to double the value"""
return 2*num
__________________ API Automation _________________
➡️ Rest Assured Using Java →    • Rest Assured  
➡️ Karate Framework using Maven →    • Karate Framework Using Maven Project  
_____________ Programing Language ____________________
➡️ Basic Python →    • Basic Python  
➡️ Core Java →    • CoreJava  
___________ Performances Testing ___________________
➡️ JMeter Beginner →    • JMeter Beginner  
➡️ Locust Beginner →    • Locust  
___________ Git and GitHub _____________________________
➡️ Git and GitHub Beginner →    • Git and GitHub Beginner  

_____________Manual Testing ____________________
➡️ Manual Testing →    • Manual Testing  

______________Automation Testing __________________
➡️ Selenium Cucumber Framework using Java →    • Selenium Cucumber BDD Framework with Java ...  
➡️ Robot Framework with Python →    • Python With Robot Framework  
➡️ Beginner Karate Framework using Intellij →    • Karate Framework Beginner  
➡️ Karate Framework with Gradle using eclipse →    • Karate Framework using Gradle Project  
➡️ Basic Selenium WebDriver using Java →    • Selenium WebDriver  
➡️ TestNG Framework →    • TestNG Framework  
➡️ Robot Framework with RIDE →    • RIDE With Robot Framework  
________________ Beginner Jenkins ____________________
➡️ Beginner Jenkins →    • Beginner Jenkins  


Auf dieser Seite können Sie das Online-Video Basic Python 6: Statement, Indentation and Comments mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Testing Tutorialspoint 13 September 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 172 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!