Programming Glossaries and Notes

Cing Sian Dal
13 min readApr 30, 2020

--

These are my notes. It is not my own work.

General notes

  • String slice [1::2]: စမှတ် by index position :: အကြိမ်မြောက်
x =['a','b','c','d','e','f'];
print("".join(x[1::2]))
// bdf
  • String slice: negative position x[-1] : နောက်ဆုံး index position ကို ယူတာ ဖြစ်ပါတယ်။
  • find() : ဘာမှမတွေ့ရင် -1 ကို အဖြေထုတ်တယ်။
  • Compound data type: heterogeneous data type ကို လက်ခံနိုင်တဲ့ data type အမျိုးအစားကို ဆိုလိုတာ ဖြစ်တယ်။
  • sum() : iterable ဖြစ်တဲ့ item အားလုံးကို ပေါင်းပစ်လိုက်တာ။
  • () > () or () < () : Tuple comparison ကို is before နဲ့ is after လိုမျိုး တွေးခေါ်ရမယ်။​
  • The list is a collection that is ordered and changeable. Allows duplicate members.
  • The tuple is a collection that is ordered and unchangeable. Allows duplicate members.
  • Set is a collection that is unordered and unindexed. No duplicate members.
  • Dictionary is a collection that is unordered, changeable, and indexed. No duplicate members.
  • Dictionary မှာ key နဲ့ value ရှိတယ်။ key က တူလို့မရဘူး။ value က ထပ်တူကျလို့ရတယ်။ အဲတာကြောင့် value ကိုရှာရင် key များစွာရှိနိုင်တယ်။
  • getcwd() : get current working directory.
  • open('file.txt','w').write('text') : string ကိုပဲ လက်ခံတယ်။ integer ထည့်လို့မရဘူး။

The way of the program

Glossary

  • problem-solving: The process of formulating a problem, finding a solution, and expressing it.
  • high-level language: A programming language like Python that is designed to be easy for humans to read and write.
  • low-level language: A programming language that is designed to be easy for a computer to run; also called “machine language” or “assembly language”.
  • portability: A property of a program that can run on more than one kind of computer.
  • interpreter: A program that reads another program and executes it
  • prompt: Characters displayed by the interpreter to indicate that it is ready to take input from the user.
  • program: A set of instructions that specifies a computation. A sequence of instructions that specifies to computer actions and computations to be performed.
  • print statement: An instruction that causes the Python interpreter to display a value on the screen.
  • operator: A special symbol that represents a simple computation like addition, multiplication, or string concatenation.
  • value: One of the basic units of data, like a number or string, that a program manipulates.
  • type: A category of values. The types we have seen so far are integers (type int), floating-point numbers (type float), and strings (type str).
  • integer: A type that represents whole numbers.
  • floating-point: A type that represents numbers with fractional parts.
  • string: A type that represents sequences of characters.
  • natural language: Any one of the languages that people speak that evolved naturally.
  • formal language: Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all programming languages are formal languages.
  • token: One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.
  • syntax: The rules that govern the structure of a program.
  • parse: To examine a program and analyze the syntactic structure.
  • bug: An error in a program.
  • debugging: The process of finding and correcting bugs. The process of finding and removing any of three kinds of programming errors.

Variables, expressions, and statements

Glossary

  • An assignment statement creates a new variable and gives it a value
  • An expression is a combination of values, variables, and operators. A value all by itself is considered an expression, and so is a variable
  • A statement is a unit of code that has an effect, like creating a variable or displaying a value.
  • variable: A name that refers to a value.
  • assignment: A statement that assigns a value to a variable.
  • state diagram: A graphical representation of a set of variables and the values they refer to.
  • keyword: A reserved word that is used to parse a program; you cannot use keywords like if, def, and while as variable names.
  • operand: One of the values on which an operator operates.
  • expression: A combination of variables, operators, and values that represents a single result.
  • evaluate: To simplify an expression by performing the operations in order to yield a single value.
  • statement: A section of code that represents a command or action. So far, the statements we have seen are assignments and print statements.
  • execute: To run a statement and do what it says.
  • interactive mode: A way of using the Python interpreter by typing code at the prompt.
  • script mode: A way of using the Python interpreter to read code from a script and run it.
  • script: A program stored in a file.
  • order of operations: Rules governing the order in which expressions involving multiple operators and operands are evaluated.
  • concatenate: To join two operands end-to-end.
  • comment: Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.
  • syntax error: An error in a program that makes it impossible to parse (and therefore impossible to interpret). “Syntax” refers to the structure of a program and the rules about that structure.
  • exception: An error that is detected while the program is running.
  • semantics: The meaning of a program.
  • semantic error: An error in a program that makes it do something other than what the programmer intended.
  • Runtime error: The second type of error is a runtime error, so-called because the error does not appear until after the program has started running. These errors are also called exceptions because they usually indicate that something exceptional (and bad) has happened. Runtime errors are rare in the simple programs you will see in the first few chapters, so it might be a while before you encounter one.
  • Order of operations: When an expression contains more than one operator, the order of evaluation depends on the order of operations. For mathematical operators, Python follows mathematical conventions. The acronym PEMDAS is a useful way to remember the rules: Parentheses, Exponentiation, Multiplication & Division, Operators with the same precedence are evaluated from left to right (except exponentiation)

Functions

Glossary

  • function: A named sequence of statements that performs some useful operation. Functions may or may not take arguments and may or may not produce a result.
  • function definition: A statement that creates a new function, specifying its name, parameters, and the statements it contains.
  • function object: A value created by a function definition. The name of the function is a variable that refers to a function object.
  • header: The first line of a function definition.
  • body: The sequence of statements inside a function definition.
  • parameter: A name used inside a function to refer to the value passed as an argument.
  • function call: A statement that runs a function. It consists of the function name followed by an argument list in parentheses.
  • argument: A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.
  • local variable: A variable defined inside a function. A local variable can only be used inside its function.
  • return value: The result of a function. If a function call is used as an expression, the return value is the value of the expression.
  • fruitful function: A function that returns a value.
  • void function: A function that always returns None.
  • None: A special value returned by void functions.
  • module: A file that contains a collection of related functions and other definitions.
  • import statement: A statement that reads a module file and creates a module object.
  • module object: A value created by an import statement that provides access to the values defined in a module.
  • dot notation: The syntax for calling a function in another module by specifying the module name followed by a dot (period) and the function name.
  • composition: Using an expression as part of a larger expression, or a statement as part of a larger statement.
  • the flow of execution: The order statements run in.
  • stack diagram: A graphical representation of a stack of functions, their variables, and the values they refer to.
  • frame: A box in a stack diagram that represents a function call. It contains the local variables and parameters of the function.
  • traceback: A list of the functions that are executing, printed when an exception occurs.
  • A module is a file that contains a collection of related functions.
  • Before we can use the functions in a module, we have to import it with an import statement: >>> import math . This statement creates a module object named math.
  • When you create a variable inside a function, it is local, which means that it only exists inside the function.
  • Some of the functions we have used, such as the math functions, return results; for lack of a better name, I call them fruitful functions.
  • Other functions, like print_twice, perform an action but don’t return a value. They are called void functions.

Case Study: Interface Design

Glossary

  • method: A function that is associated with an object and called using dot notation.
  • loop: A part of a program that can run repeatedly.
  • encapsulation: The process of transforming a sequence of statements into a function definition.
  • generalization: The process of replacing something unnecessarily specific (like a number) with something appropriately general (like a variable or parameter).
  • keyword argument: An argument that includes the name of the parameter as a “keyword”.
  • interface: A description of how to use a function, including the name and descriptions of the arguments and return value.
  • refactoring: The process of modifying a working program to improve function interfaces and other qualities of the code.
  • development plan: A process for writing programs.
  • docstring: A string that appears at the top of a function definition to document the function’s interface.
  • precondition: A requirement that should be satisfied by the caller before a function starts.
  • postcondition: A requirement that should be satisfied by the function before it ends.

Conditionals and recursion

Glossary

  • floor division: An operator, denoted //, that divides two numbers and rounds down (toward negative infinity) to an integer.
  • modulus operator: An operator, denoted with a percent sign (%), that works on integers and returns the remainder when one number is divided by another.
  • boolean expression: An expression whose value is either True or False.
  • relational operator: One of the operators that compare its operands: ==, !=, >, <, , and
  • logical operator: One of the operators that combine boolean expressions: and , or, and not.
  • conditional statement: A statement that controls the flow of execution depending on some condition.
  • condition: The boolean expression in a conditional statement that determines which branch runs.
  • compound statement: A statement that consists of a header and a body. The header ends with a colon (:). The body is indented relative to the header.
  • branch: One of the alternative sequences of statements in a conditional statement.
  • chained conditional: A conditional statement with a series of alternative branches.
  • nested conditional: A conditional statement that appears in one of the branches of another conditional statement.
  • return statement: A statement that causes a function to end immediately and return to the caller.
  • recursion: The process of calling the function that is currently executing.
  • base case: A conditional branch in a recursive function that does not make a recursive call.
  • infinite recursion: A recursion that doesn’t have a base case, or never reaches it. Eventually, an infinite recursion causes a runtime error.

Fruitful functions

Glossary

  • temporary variable: A variable used to store an intermediate value in a complex calculation.
  • dead code: Part of a program that can never run, often because it appears after a return statement. Code that appears after a return statement, or any other place the flow of execution can never reach, is called dead code. This function is incorrect because if x happens to be 0, neither condition is true, and the function ends without hitting a return statement.
def absolute_value(x):
if x < 0:
return -x
else:
return x
  • incremental development: A program development plan intended to avoid debugging by adding and testing only a small amount of code at a time.
  • scaffolding: Code that is used during program development but is not part of the final version.
  • guardian: A programming pattern that uses a conditional statement to check for and handle circumstances that might cause an error.
  • precondition: function ထဲကို ထည့်လိုက်တဲ့ value (argument) ကိုက အမှားဖြစ်နေတာ။
  • postcondition: function ကိုက တစ်ခုခုမှားနေတာ။
  • In fact, you are already practicing this leap of faith when you use built-in functions. When you call math.cos or math.exp, you don’t examine the bodies of those functions. You just assume that they work because the people who wrote the built-in functions were good programmers.

Iteration

Glossary

  • The flow of execution for while is:
(1) Determine whether the condition is true or false(2) If false , exit the while statement, and continue execution at the next statement.(3) If the condition is true , run the body, and then go back to step 1.
  • reassignment: Assigning a new value to a variable that already exists.
  • update: An assignment where the new value of the variable depends on the old.
  • initialization: An assignment that gives an initial value to a variable that will be updated.
  • increment: An update that increases the value of a variable (often by one).
  • decrement: An update that decreases the value of a variable.
  • iteration: Repeated execution of a set of statements using either a recursive function call or a loop.
  • infinite loop: A loop in which the terminating condition is never satisfied.
  • algorithm: A general process for solving a category of problems.

String

Glossary

  • object: Something a variable can refer to. For now, you can use “object” and “value” interchangeably.
  • sequence: An ordered collection of values where each value is identified by an integer index.
  • item: One of the values in a sequence.
  • index: An integer value used to select an item in a sequence, such as a character in a string. In Python, indices start from 0.
  • slice: A part of a string specified by a range of indices.
  • empty string: A string with no characters and length 0, represented by two quotation marks.
  • immutable: The property of a sequence whose items cannot be changed.
  • traverse: To iterate through the items in a sequence, performing a similar operation on each.
  • traversal: A lot of computations involve processing a string one character at a time. Often they start at the beginning, select each character in turn, do something to it, and continue until the end. This pattern of processing is called a traversal.
  • search: A pattern of traversal that stops when it finds what it is looking for.
  • counter: A variable used to count something, usually initialized to zero and then incremented.
  • invocation: A statement that calls a method.
  • optional argument: A function or method argument that is not required.

Lists

Glossary

  • list: A sequence of values. key of list can accept tuple type.
  • element: One of the values in a list (or other sequences), also called items.
  • nested list: A list that is an element of another list.
  • accumulator: A variable used in a loop to add up or accumulate a result.
  • augmented assignment: A statement that updates the value of a variable using an operator like += .
  • reduce: A processing pattern that traverses a sequence and accumulates the elements into a single result.
  • map: A processing pattern that traverses a sequence and performs an operation on each element.
  • filter: A processing pattern that traverses a list and selects the elements that satisfy some criterion.
  • object: Something a variable can refer to. An object has a type and a value.
  • equivalent: Having the same value.
  • identical: Being the same object (which implies equivalence).
  • reference: The association between a variable and its value.
  • aliasing: A circumstance where two or more variables refer to the same object.
  • delimiter: A character or string used to indicate where a string should be split.

Dictionaries

Glossary

  • mapping: A relationship in which each element of one set corresponds to an element of another set.
  • dictionary: A mapping from keys to their corresponding values.
  • key-value pair: The representation of the mapping from a key to a value.
  • item: In a dictionary, another name for a key-value pair.
  • key: An object that appears in a dictionary as the first part of a key-value pair.
  • value: An object that appears in a dictionary as the second part of a key-value pair. This is more specific than our previous use of the word “value”.
  • implementation: A way of performing a computation.
  • hashtable: The algorithm used to implement Python dictionaries.
  • hash function: A function used by a hashtable to compute the location for a key.
  • hashable: A type that has a hash function. Immutable types like integers, floats, and strings are hashable; mutable types like lists and dictionaries are not.
  • lookup: A dictionary operation that takes a key and finds the corresponding value. key နဲ့ စစ်ရှာပြီး value (return) ကိုထုတ်တယ်။
  • reverse lookup: A dictionary operation that takes a value and finds one or more keys that map to it. Value နဲ့ စစ်ရှာပြီး key (return) ကို ထုတ်တယ်။
  • raise statement: A statement that (deliberately) raises an exception.
  • singleton: A list (or other sequences) with a single element.
  • call graph: A diagram that shows every frame created during the execution of a program, with an arrow from each caller to each callee.
  • memo: A computed value stored to avoid unnecessary future computation.
  • global variable: A variable defined outside a function. Global variables can be accessed from any function.
  • global statement: A statement that declares a variable name global.
  • flag: A boolean variable used to indicate whether a condition is true.
  • declaration: A statement like global that tells the interpreter something about a variable.

Files

Glossary

  • persistent: Pertaining to a program that runs indefinitely and keeps at least some of its data in permanent storage.
  • format operator: An operator, %, that takes a format string and a tuple and generates a string that includes the elements of the tuple formatted as specified by the format string.
  • format string: A string, used with the format operator, that contains format sequences.
  • format sequence: A sequence of characters in a format string, like %d, that specifies how a value should be formatted.
  • text file: A sequence of characters stored in permanent storage like a hard drive.
  • directory: A named collection of files, also called a folder.
  • path: A string that identifies a file.
  • relative path: A path that starts from the current directory.
  • absolute path: A path that starts from the topmost directory in the file system.
  • catch: To prevent an exception from terminating a program using the try and except statements.
  • catching: Handling an exception with a try statement is called catching an exception.
  • database: A file whose contents are organized like a dictionary with keys that correspond to values.
  • bytes object: An object similar to a string.
  • shell: A program that allows users to type commands and then executes them by starting other programs.
  • pipe object: An object that represents a running program, allowing a Python program to run commands and read the results.

Case Study

Glossary

  • file object: A value that represents an open file.
  • reduction to a previously solved problem: A way of solving a problem by expressing it as an instance of a previously solved problem.
  • special case: A test case that is atypical or non-obvious (and less likely to be handled correctly).

Mental Landscape

Glossary

  • What is this?

Names and Things

Glossary

  • What is this?

References

  • Downey, A. (2015). Think Python, How to think like a computer scientist.
  • David, J. E. (2009). Introduction to Programming Using Java.

--

--

Cing Sian Dal
Cing Sian Dal

Written by Cing Sian Dal

Don’t follow me. I wrote junks here. Follow me on Twitter instead.

No responses yet