GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.tutorialsteacher.com — Python Syntax Python SyntaxHere, you will learn the basic syntax of Python 3. Display OutputThe Example: Display Output By default, a single space Getting User's InputThe input() function is used to get the user's input. It reads the key strokes as a string object which can be referred to by a variable having a suitable name. ![]() Note that the blinking cursor waits for the user's input. The user enters his input and then hits Enter. This will be captured as a string. In the above example, the The ![]() The Python StatementsPython statement ends with the token NEWLINE character (carriage return). It means each line in a Python script is a statement. The following Python script contains three statements in three separate lines. Example: Python Statements Please note that the backslash character spans a single line in one logical line and multiple physical lines, but not the two different statements in one logical line. Use the semicolon Example: Multiple Statements in Single Line Code Comments in PythonIn a Python script, the symbol # indicates the start of a comment line. It is effective till the end of the line in the editor. Example: Single Line Comment In Python, there is no provision to write multi-line comments, or a block comment. For multi-line comments, each line should have the A triple quoted multi-line string is also treated as a comment if it is not a docstring of the function or the class. Example: Multi-line Comments Visit PEP 8 style Guide for Python Code for more information. Indentation in PythonLeading space or tab at the beginning of the line is considered as indentation level of the line, which is used to determine the group of statements. Statements with the same level of indentation considered as a group or block. For example, functions, classes, or loops in Python contains a block of statements to be executed. Other programming languages such as C# or Java use curly braces Indentation Rules
The following example demonstrates if elif blocks: Example: Python if Block A function contains all the same level indented statements. The following function contains a block with two statements. Example: Python Function Block The following example illustrates the use of indents in Python shell: ![]() As you can see, in the Python shell, the Python Naming ConvetionsThe Python program can contain variables, functions, classes, modules, packages, etc. Identifier is the name given to these programming elements. An identifier should start with either an alphabet letter (lower or upper case) or an underscore (_). After that, more than one alphabet letter (a-z or A-Z), digits (0-9), or underscores may be used to form an identifier. No other characters are allowed.
Visit PEP 8 - Prescriptive Naming Conventions for more information. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |