Appendix

Keywords, Identifiers, Geometry Concepts, etc.

The Appendix page lists useful information regarding Keywords, Identifiers, Comparison Operators, Decimal and Binary systems, etc.

Appendix – Python Comments

A comment starts with a hash character (#) that is not part of a string literal and ends at the end of the physical line. All characters after the hash character (#) and up to the end of the physical line are part of the comment; the Python interpreter ignores them.

Here are some examples of comments.

>>> # This is my first Python program. 

In the above example, all characters from the hash character sign to the end of the line are ignored by Python.

You can type a comment on the same line after a statement or expression as below.

>>> print(“My name is Robert.”)  # Another comment.

Multi-line comments: If your comment is long, you can do it on multiple lines using triple single quotes (‘’’). The following triple-quoted string is ignored by the Python interpreter and is treated as a comment:

>>> ‘’’ This is

>>> a multi-line

>>> comment.”’

Appendix – Quotations in Python

Python accepts single (‘), double (“), and triple (”’ or “””) quotes to denote string literals, as long as the same type of quote starts and ends the string.

If your string is long, you can use triple quotes to type the string across multiple lines.

Below is an example of string literals with a single quote (‘), double quote (“), and triple quote.

>>> literal1 = ‘literal using single quotes’

>>> literal2 = “literal using double quotes”

>>> multilineLiteral = ‘’’This literal is composed of

multiple lines.’’’

Python Identifiers

A Python identifier is a name used to identify a variable, function, class, module, or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9). Python does not allow punctuation characters such as @, $, and % within identifiers. Identifiers are case sensitive, therefore, an identifier name such as ‘abc’ is different from ‘Abc’ or ‘aBc’ etc.

Naming conventions for Python identifiers:

  • Class names start with an uppercase letter. All other identifiers start with a lowercase letter.
  • Starting an identifier with a single leading underscore indicates that the identifier is private.
  • Starting an identifier with two leading underscores indicates a strongly private identifier.
  • If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.

Source: https://docs.python.org/3/reference/lexical_analysis.html#identifiers

Python Keywords

Python uses the following identifiers as reserved words, or keywords, You cannot use the keywords as user-defined identifiers, constants, or variables.  All Python keywords are lowercase only. They must be spelled exactly as written here:

andExecnot
assertFinallyor
breakForpass
classFromprint
continueGlobalraise
defIfreturn
delImporttry
elifInwhile
elseIswith
exceptLambdayield
PYTHON KEYWORDS

Python Comparison Operators

The following is a list of Python Comparison Operators.

https://docs.python.org/3/reference/lexical_analysis.html#operators

+   –   *   **  /   //  %   @
<<  >>   &   |   ^   ~   := 
  >   <=  >=  ==  !=  
PYTHON COMPARISON OPERATORS

Python Built-in Functions

Python distribution comes with the following built-in functions. For details of these functions, refer to this link.

Source: https://docs.python.org/3/library/functions.html#functions

abs()delattr()hash()memoryview()set()
all()dict()help()min()setattr()
any()dir()hex()next()slice()
ascii()divmod()id()object()sorted()
bin()enumerate()input()oct()staticmethod()
bool()eval()int()open()str()
breakpoint()exec()isinstance()ord()sum()
bytearray()filter()issubclass()pow()super()
bytes()float()iter()print()tuple()
callable()format()len()property()type()
chr()frozenset()list()range()vars()
classmethod()getattr()locals()repr()zip()
compile()globals()map()reversed()__import__()
complex()hasattr()max()round()
PYTHON BUILT-IN FUNCTIONS

ASCII Code Tables

The table shows how the computer stores the numbers, alphabets, and symbols as 8-bit codes.

Decimal = Decimal Value

Char = Character

DECIMALCharDecimalCharDecimalCharDecimalChar
0NUL(null)32SPACE64@96`
1SOH(start of heading)33!65A97a
2STX(start of text)3466B98b
3ETX(end of text)35#67C99c
4EOT(end of transmission)36$68D100d
5ENQ(enquiry)37%69E101e
6ACK(acknowledge)38&70F102f
7BEL(bell)3971G103g
8BS(backspace)40(72H104h
9TAB(horizontal tab)41)73I105i
10LF(NL line feed, new line)42*74J106j
11VT(vertical tab)43+75K107k
12FF(NP form feed, new page)44,76L108l
13CR(carriage return)4577M109m
14SO(shift out)46.78N110n
15SI(shift in)47/79O111o
16DLE(data link escape)48080P112p
17DC1(device control 1)49181Q113q
18DC2(device control 2)50282R114r
19DC3(device control 3)51383S115s
20DC4(device control 4)52484T116t
21NAK(negative acknowledge)53585U117u
22SYN(synchronous idle)54686V118v
23ETB(end of trans. block)55787W119w
24CAN(cancel)56888X120x
25EM(end of medium)57989Y121y
26SUB(substitute)58:90Z122z
27ESC(escape)59;91[123{
28FS(file separator)6092\124|
29GS(group separator)61=93]125}
30RS(record separator)6294^126~
31US(unit separator)63?95_127DEL
ASCII CODES

Example 1:

Character ‘5’ has the integer value 53.

Character ‘0’ has the integer value 48.

String arithmetic ‘5’ – ‘0’ will evaluate to 53 – 48, or the int 5.

Example 2:

Char ‘a’ = decimal 97

Char ‘A’ = decimal 65

‘a’ – ‘A’ will evaluate to 97 – 65 = 32

c = ‘B’+32 = 66 + 32 = 98, which is the ASCII code for ‘b’. Therefore, variable  ‘c’ stores character ‘b’.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Verified by MonsterInsights