Computing Module - Final Exam Flashcards
Arguments
Pieces of data that are sent to a function, which the function uses in calculations or other operations
Parameter Variables
Represent the inputs to the function, and are assigned the value of the arguments
Value-Returning Functions
Returns a value back to the part of the program that called it, used when the function should explicitly return a value. If a function contains NO return statement, None is automatically returned.
Lists
A collection variable that has an ordered sequence of elements, each element inside the list is called an item.
A list can hold multiple types of data
Count-Controlled Loops
A loop that iterates a specific number of times, and is written using a “for” statement. The for statement executes once for each item in the sequence.
Condition-Controlled Loops
A loop that will iterate as long as a condition is true, and is written using a “while” statement. The statement(s) under while loop iterate as long as the condition is true.
If statements
One way selection instruments, prevents an action from being performed if a condition is not right
If-else statements
Two-Way selection instruments, makes a choice between two alternative courses of action
If-elif-else statements
Multi-Way selection instruments, consider each condition until one evaluates to true or they all evaluate to false
Nested Decision Structures
Allow for consecutive decisions to be made, and a condition inside will only evaluate if the first condition evaluates to True
Nested Repetition Structures
A loop inside a loop, an inner loop goes through all of its iterations for one iteration of the outer loop
Preventing Software Bugs
Object oriented programming can improve the structure of large software systems, and software testing techniques can be developed and promoted
Black Box Software Testing
testing code without considering how it works, e.g we check to see if a given input produces desired output
White Box Software Testing
testing code knowing how coed is supposed to work, e.g. we check to see if each condition of an if statement will work when expected
Integration Software Testing
testing different sections of code working together; lets us test communication between different sections of code
Unit Software Testing
testing a specific section of code, e.g testing a single function
Software Bugs
error or flaw in computer program, causing unexpected results or incorrect behaviour
Test Plan
created to finding as many software bugs as possible, and ensuring software is bug free before release
Test Plan Cases
Normal Cases - expected inputs that produce a specific result
Boundary Cases- inputs that lie close to some parameter
Abnormal cases- empty lists, strings, files
Each input should have an expected output, if expected output does not match actual output, the result is a fail and vice versa
Text File
contains data that has been encoded as a text; using scheme such as ASCII or unicode
Binary File
contains data that has not been converted to text
File I/O
consists of opening, reading, modifying, and closing files; it can help with analyzing, interpreting, and storing data with python
Open function
‘r’ - open for reading only
‘w’- open file for writing
‘a’ - open a file to be written to
.read()
reads entire contents of file, and returns riles contents as string
.readline()
reads single line from a file and returns next line in file including the /n
.readlines()
reads entire contents of a file, and returns the entire content as a list where each item is a line, including the /n
Strings
an IMMUTABLE sequence of characters, they are used to store and represent textual data
.split()
allows splitting of string into substrings, the default separator is whitespace (e.g space, /t, /n)
.write()
writes data to a file, the value inside the parentheses is written to the file
.writelines()
writes list of strings to file, the list inside the parentheses has to have all elements as strings
object-oriented programming
programmers define the data type of a data structure, and also the types of operations that can be applied to the data structure
procedural programming
a program made up of one or more procedures; data is passed from one procedure to another, the focus is the creation of procedures that operate on the program’s data
Object Data Attributes
data contained in an object, i.e variables that contain data
each object shares the same attributes, but the value of the attributes is what differentiates them
Object Methods
procedures that a object performs; i.e functions that perform objects on the objects data attributes
Class
logical grouping of data and functions, defines the data that objects of the class can have and defines the methods that objects of that class can have
Objects
an instance of a class, we can create as many objects of a class as we want
Methods
a function defined in a class, they have access to all the data contained on the instance of an object
they define what an object can do
__init__ method
special method that constructs an object of a class
- python automatically runs the __init__ method to initialize objects attributes
self parameter
self is NOT an argument passed to the object, rather self is the instance of the Student
Accessor Methods
allow user to observe but not change the state of an object, do not take arguments and often include return statement
Mutator Methods
allows user to modify an object’s state; often begin with set, mutator methods often take arguments that are used to modify existing instance variable