click below
click below
Normal Size Small Size show me how
Python
Question | Answer |
---|---|
print(“my” “name”, sep=“-“) | |
print("My", "name", "is", sep="_", end="*") print("Monty", "Python.", sep="*", end="*\n") | |
function invocation/call | |
collections of instructions | Computer programs |
a special character which announces that the next character | backslash (\) |
Positional arguments | the ones whose meaning is dictated by their position, e.g., the second argument is outputted after the first, the third is outputted after the second, etc. |
Keyword arguments | the ones whose meaning is not dictated by their location, but by a special word (keyword) used to identify them |
instruction list | A complete set of known commands |
lexis (aka a dictionary) | a set of words the language offers its users (e.g., the word "computer" comes from the English language dictionary, while "cmoptrue" doesn't; the word "chat" is present both in English and French dictionaries, but their meanings are different) |
syntax | a set of rules (formal or informal, written or felt intuitively) used to determine if a certain string of words forms a valid sentence (e.g., "I am a python" is a syntactically correct phrase, while "I a python am" isn't) |
semantics | a set of rules determining if a certain phrase makes sense (e.g., "I ate a doughnut" makes sense, but "A doughnut ate me" doesn't) |
compilation | the source program is translated once (however, this act must be repeated each time you modify the source code) by getting a file containing the machine code the program that performs this translation is called a compiler or translator |
interpretation | you (or any user of the code) can translate the source program each time it has to be run. The program performing this kind of transformation is called an interpreter, as it interprets the code every time it is intended to be executed. |
literal | data whose values are determined by the literal itself. |
type | The characteristic of the numeric value which determines its kind, range, and application |
numeric literal symbols | 11111111, Python 3.6 has introduced underscores in numeric literals.This feature is not available in older versions of Python.or like this: 11_111_111 |
0o123 | octal, 83 |
0x123 | hexadecimal, 291 |
(as a mathematician would say) have a non-empty decimal fraction | represent and to store the numbers floating-point |
\" | backslash escape character |
Boolean values have strict denotations in Python | True False including case-sensitivity. |
None | NoneType absence of a value |
Integer division (floor division) | // rounding always goes to the lesser integer. |
print(12 % 4.5) | 3.0 |
left-sided binding | print(9 % 6 % 2) = 1 |
the exponentiation operator uses | right-sided binding print(2 ** 2 ** 3) = 256 |
arithmetic operator priority | Priority Operator 1 ** 2 +, - (note: unary operators located next to the right of the power operator bind more strongly) unary 3 *, /, //, % 4 +, - binary |
variable rules | must be composed of upper-case or lower-case letters, digits, and _ must begin with a letter; the underscore character is a letter; upper- and lower-case letters are treated as different; must not be any of Python's reserved words (the keywords |
variable name conventions | should be lowercase, with words separated by underscores to improve readability function names follow the same convention as variable names it's also possible to use mixed case (e.g., myVariable) |
reserved keywords | False, None, True, and, as, assert, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield |
input() | |
type casting | int( ) float( ) str() |
replication operator | * |
The \n digraph forces the print() function to: | new line |
== | binary operator with left-sided binding |
equality priority | Priority Operator 1 +, - unary 2 ** 3 *, /, //, % 4 +, - binary 5 <, <=, >, >= 6 ==, != |
convention indentation | four spaces of indentation |
binary shift priority | Priority Operator 1 ~, +, - unary 2 ** 3 *, /, //, % 4 +, - binary 5 <<, >> 6 <, <=, >, >= 7 ==, != 8 & 9 | 10 =, +=, -=, *=, /=, %=, &=, ^=, |=, >>=, <<= |
<< / >> | binary shifting |
scalar | variables that are able to store exactly one given value at a time element in collection |
two-dimensional array | matrix |