CA2 Flashcards
State:
“True or false value”
Boolean
Define:
Character
“Single character which can be a letter, number or symbol”
Define:
Integer
“Whole numbers, positive or negative”
State:
“Any number, with or without decimal places, positive or negative”
Real/Float
Define:
String
“A group of characters stored together”
Define:
Immutable
“When the value of a number data type changes, a new object is created”
Define:
Casting
“Converting a variable from one data type to another”
Define:
Data Structures
“Collection of data objects which facilitate the storing and managing of data in a program”
State:
2 advantages of using data structures
- Optimise memory usage within a system
- Can be reused and compiled into libraries
State:
“A collection of data items, can be of different data types and items are accessed using each data items index value”
List
State:
“Contains a group of elements of the same data type”
Array
Define:
Dictionary
“A set of values, each with associated keys. Items are unordered and when accessed by the key, will return the associated value”
Define:
Index
“A numerical representation of an item’s position in a sequence”
Define:
Scope
“Where a variable can be accessed within a program”
Fill The Blank:
A ………. variable is only accessable in a pre-determined part of a program
Local
Fill The Blank:
Two variables can use the same identifier if they are in different ………. because they are in a seperate area in ………
Scopes, RAM
Fill The Blank:
The scope of a local variable is the ………… where it has been ………..
Subprogram, Declared
Fill The Blank:
The scope of a global variable is the …………. program
Complete
State:
Where global variables are declared
Start of the program
State:
Where local variables are declared
Declared within subroutines or programming blocks and can only be used within the scope it is declared in
Define:
Snakecase
Where words are delimited using underscores: Variable_a
Define:
Camelcase
All words are started with a capital letter, apart from the first word with no spaces: variableA
Define:
Pascalcase
words are started by capital letters: VariableA
Define:
Hungarian Notation
Describe the purpose and/ore type of variable at the start followed by a descriptor that states the function of the variable: iStudentMarks
Fill The Blank:
It is important variable names are ……………. and easily ……………… and understandable.
Consistent, Readable
State:
Add Operator
+
State:
Subtract Operator
-
State:
Multiply Operator
*
State:
Divide Operator
/
State:
Integer Division Operator
// (DIV)
State:
Modulus
% (MOD)
State:
Equal To Operator
==
State:
Not Equal To Operator
!= or <>
State:
Greater Than
>
State:
Greater Than OR Equals
> =
State:
Less Than
<
State:
Less Than OR Equal To
<=
Explain:
AND
True if both are true
Explain:
NOT
Input is reversed
Explain:
OR
True if EITHER inputs are true
Fill The Blank:
Python treats files as either ……. or ……….. depending on the …………. of the file
Text, Binary, Contents
State:
When open() is used it requires two parameters, requiring the …….. ……….. and ………
File Name, Mode
State:
4 different modes of opening a file
Append “a” - appending (editing) a file
Create “x” - create the specified file
Read “r” - open file for reading
Write “w” - open a file for writing (overwrites current contents)
State:
How to close a file
{filevariablename}.close()
Fill The Blank:
If when creating a file (using “x”) and the file ….. then it returns an error
Exists
State:
3 constructs used when creating algorithms
- Sequence
- Selection (branching)
- Iteration
Define:
Sequence
Running a list of instructions in a strict order, the main logical structure of algorithms and programs
Define:
Selection
Making a decision to dictate the flow of a program
Define:
Iteration
Repeating a set of instructions
Define:
Sequencing
Order in which the program code is executed
State:
What ‘IDLE’ stands for
Integrated Development Learning Environment
State:
Why the IDLE is useful
Identifying mistakes; syntax and runtime errors
Fill The Blank:
Not all devices have debuggers, especially not ….. devices. If a device has no debugger then you can use ……….. debugging
IoE, Print
Fill The Blank:
Debugging can be …….. ………… and not …….. to use
Time Consuming, Easy
Fill The Blank:
In early versions of ……….. there was no …….. statement and developers had to use …………… mapping
Python, Case, Dictionary
Define:
Dictionary
Iterable data structure built in to Python that contains a series of values with corresponding keys
State:
3 uses of iteration
- Adding numbers
- Repeating functions
- Cycling through values
State:
Statement used to force a loop to stop (even if a condition is true)
break
State:
How to run a block of code after a for or while loop has been completed - that is not needed because it continues anyway
else:
State:
Statement used to stop the current iteration and continue with the next iteration
continue
Fill The Blank:
When code does not function how it is intended, it is necessary to …….. it
Debug
State:
Give 3 examples of mistakes that could cause error messages
3 of:
* Syntax error OR within syntax error:
* Missing punctuation
* Typing errors in commands/Python
* Missing indentations
Define:
Function
Code written to perform a specific task and can be used more than once
Define:
Built-in Functions
Functions included in the programming language
Define:
User-defined functions (UDFs)
Functions that can be created by software developers
Define:
Anonymous Function
Also known as lambda functions, functions not declared with the standard keyword (‘def’ in Python)
Define:
Method
A function that is part of a class and is accessed using an instance or object of a class
Define:
Arguments
Value that is sent to a function
Define:
Parameter
Variable that is listed inside the parentheses of a function
State:
2 requirements of a procedure
- Name
- Programming code to perform required task (code block)
State:
Difference between Procedure & Function
Function: Returns a value and control, compiled before and re-compiled if needed - with different parameter values
Procedure: Returns the control but no value, only compiled once - no values will change, a paramater value once accepted once cannot change
State:
Another name for linear search
Serial search
State:
How a linear search functions
Starting at the beginning of the dataset, each value is examined until a match is made
Fill The Blank:
Binary Search is a ……. search algorithm and works on the principle of ………… and ………….
Fast, Divide, Conquer
State:
What is one requirement of Binary Search
Data is in a sorted format
Fill The Blank:
The search ……….. is repeatedly …………. in half. If the middle value is greater than the value of the search then the interval is changed to the ……….. half of the array. If the middle value is lower than the value of the search then the interval is changed to the ………. half of the array.
This is ………….. until the value is found or the interval is …………
Steps of binary search
Interval, Divided, Lower, Upper, Repeated, Empty
State:
3 advantages of using linear search
3 of:
* List does not have to be ordered
* Fast performance when searching small to medium lsits
* Because list is not sorted, elements can be added and deleted - if needed to be sorted re-ordering would be needed
* Linear search is simpler and easier to implement
* Can be used on any type of data
State:
1 advantage of binary search
Faster performance than linear search because the data being searched is halfed at each stage
State:
1 disadvantage of linear search
Very slow when searching lists with large quantitiese of data items
State:
1 disadvantage of binary search
Data must be ordered/sorted first
Define:
Pre-written code
Code that already exists when developing new software either within your own organisation or from an external source
State:
3 ways that code can be reused
- Using third party libraries
- Open-sourced frameworks
- Repurposing code that has been used/developed/written internally