1/111
Vocabulary flashcards related to Computer Science basics and Python programming.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Computer Science
The study of computer software, algorithms, abstractions, and efficiency, as well as the theoretical foundation of computation.
Algorithm
A set of steps to complete a task; must be precise, repeatable, predictable, executable, and have an end.
Programming Process
Ingesting info from the real world, processing data, and sending data back to the real world.
Sequence
Steps flow in order.
Selection
A choice must be made.
Iteration
The repetition of steps.
Algorithms
Written in natural language.
Programming Languages
Written with strict rules.
Python
Uses .py file. A set of instructions executed by an interpreter. An Object-Oriented Programming language.
Compile
Take a piece of code that a human can understand and turn it into something a computer can run.
Compiler
Compiles all of the code of a computer at once.
Interpreter
Compiles code line by line.
IDE
An application used to help someone create code.
Literals
Actual data values.
Operators
+, -, *, /, %, **, etc.
Comment
A part of the code ignored by Python, intended to help a human reader.
Function
A named sequence of instructions that perform a collective purpose.
Argument
An argument is part of a function.
Identifier
A word used to name a function and variable.
Variable
A container for data named using the rules for identifiers.
Expression
Combines variables, literals, and operators.
Syntax
The fundamental rules of a programming language.
eval() Function
Evaluates a string as a python expression and returns the most appropriate type (e.g. int() or float() ).
Boolean_expression
Evaluates to either True or False.
Boolean
Stores either True or False.
AND
Returns True only if both operands are True.
OR
Returns True if at least one of the operands is True.
NOT
Inverts the boolean value.
Hierarchy
Operators are evaluated in a specific order. Higher precedence operators are evaluated before those with lower precedence.
Conditional expression
An expression that compares values using conditional operators, and which evaluates to a boolean.
Boolean expression
An expression that combines boolean operands using boolean operators, and which evaluates to a boolean.
Iteration
The process of executing the same block of code or a set of statements multiple times.
For Loop
Repeats a specific number of times. Also known as a definite loop.
While Loop
Repeats while a condition is true. It is an indefinite loops as it doesn't run a fixed number of times.
Continue
Skips the rest of the current iteration and returns to the top of the loop.
Break
Completely escapes from the loop.
Nested statements
Placing a statement inside another (e.g., if/else/for inside if/else/for ).
Nested loop
placing a for or while loop within another for/while loop.
Terminating Value / Sentinel
A value that indicates the end of a sequence of data or the termination of a loop.
Arrays
An indexed sequence of values associated with one variable.
Static array
Length cannot be changed (usually in compiled languages)
Dynamic array
Lengths can be changed (usually in interpreted languages)
'IndexError'
A runtime error that occurs when a list index is out of range.
In-place Function
Modifies the original list.
Mutability
Describes the ability to change the values within an object. Lists and dictionaries are mutable. Strings are immutable.
2D array
A list of lists. You need two indexes to access an element (e.g., arr[0][0] ).
Dictionaries
A set of key-value pairs.
String
A list of characters.
Objects
A datatype that combines data and functions (called methods).
ASCII
A more limited system for character representation.
len(string)
Returns the length of a string.
String Slicing
Extracts a portion of a string.
s.format()
Formats a string, using placeholders like {}.
Purpose
Make programs readable and modular; Refactor code to avoid duplication.
Parameter
Variables defined in a function's definition when creating the function.
Argument
Values that are provided for each parameter when a function is invoked.
Scope
The part of a program where a variable is accessible or modifiable. Variables created in a function are local.
Lifetime
Duration for which a variable exists (e.g., local variables are deleted at the end of a function).
Docstrings
Specify the purpose in a string immediately after the function header (ideally a multiline string – """ """).
Modules
Any python program with functions can be imported and used by another program.
Testing
Checking if there are any errors; It only demonstrates that no errors have been found; there could still be errors.
Debugging
To find the cause of a known error and repair it.
Compile-time errors
Errors picked up by the compiler during compilation; usually syntax errors.
Runtime errors
Errors that occur when code is executed.
Syntax error
Program does not pass checking/compiling due to improper use of python language (e.g. typo, incorrect indentation, division by zero).
Logic errors
Program passes checking/compiling and runs, but produces incorrect output (or no output) due to flaws in algorithm or implementation.
Exhaustive testing
Run program using all possible input and compare actual output to expected. Ideal, but unrealistic.
Random testing
Testing a random subset of values in the input domain (using a random number generator). It is important to ensure values are distributed over the input domain. Unreliable so should be avoided.
Equivalence Classes
Group values into sets of values with similar expected behavior.
Boundary Values
Choose values at the boundaries of equivalence classes.
Path Testing
Create test cases to cover *all paths of execution of the program at least ones. Hence every combination of statements is executed.
Statement Coverage
Create test cases to ensure that all statements are executed at least once.
Black Box Testing
You cannot access the actual code.
Glass Box Testing
You can access the actual code.
Tracing
Insert temporary print statements into code to output values during calculation ("trace instructions").
Debugging
The process of finding errors in code (using a debugger).
Debugger
A tool for executing an application where the programmer can carefully control execution and inspect data.
Recursion
A recursive function is a function that calls itself based on the problem- solving technique of breaking down a task into subtasks.
Stopping condition (or base case)
Ensures the function eventually stops recursing.
Cons
Recursion is not absolutely necessary – any recursive task can be done non- recursively using loops.
Data Storage
Data in a computer is stored in files.
File Extensions
All files have a file extension (e.g., .py, .txt) which indicates the file's contents or intended use.
Text Files (.txt)
Made of strings that end with a newline ( \n ).
Binary Files
Store info in application-specific formats (e.g., .pdf, .jpg).
Encoding
The encoding method indicates how the symbols were converted to binary (e.g. 'ASCII', unicode ('utf-8')).
"r" : Read mode
Reads existing file (IOError if file doesn't exist).
"w" : Write mode
Overwrites existing file (or creates new file) for writing.
"a" : Append mode
Opens file (or creates new one) and moves cursor to end for writing.
"x" : Exclusive creation mode
Exclusive creation mode for writing (IOError if file exists).
f.close()
Always close the file after interacting with it! This saves releases the file so that others can interact with the file.
f.read(n)
Reads at most n bytes or the entire contents of the file into a string; n is optional.
print("…" , file=f)
Outputs a string to a file, adding \n by default.Works just like normal print (but doesn't print to console). Can take multiple expressions.
Exceptions
Unexpected events or conditions that disrupt the normal flow of execution in a program.
FileNotFoundError
file doesn't exist (e.g. when using "r" mode)
FileExistsError
file already exists (e.g. when using "x" mode)
Linear Search
Starts at one end of the list and checks each element until either the target is found or the list ends.
Binary Search
Only works on sorted lists. Divides the search interval in half repeatedly - divide & conquer.
Selection Sort
Selects the smallest item in the list and swaps it with the first item, then repeats for the rest of the list until fully processed.
Merge Sort
Divides the list into n sublists and repeatedly merges them producing sorted sublists until one sorted sublist remains.
Quick Sort
Partitions the list based on a pivot value, then sorts each partition recursively.