COMPUTER SCIENCE CHAPTER 1 - PROGRAMMING Flashcards

(95 cards)

1
Q

data type

A

data that we use and store in computer programs that come in various shapes and sizes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

data types

A

-integer
-real/double
-boolean
-character
-string
-records
-arrays
-date/time
-pointer/reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

primitive data type

A

-supported by all languages
-any basic data type provided by a language as a foundational building block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

composite data type

A

built by combining other data types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

integer:

A

-any positive or negative whole number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

real/double

A

-decimal / fractional numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

boolean

A

-value which is either true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

pointer/reference

A

a way of storing memory address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

string

A

-sequence of characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

character

A

-single number or letter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

user defined data type

A

derived from existing data types in order to create a customised data structure,, ensures it is memory efficient

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

programming concepts:

A

-variable declaration
-constant declaration
-assignment
-iteration
-selection
-subroutine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

variable declaration:

A

-creating a variable type and giving it a name or sometimes a data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

constant declaration:

A

-same as variable declaration but when creating the constant the value of it doesn’t change while the program is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

assignment:

A

-giving a constant or variable a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

iteration:

A

-repeating a instruction can be definite or indefinite

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

selection:

A

-comparing values and choosing a action based on the values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

subroutine:

A

-block of code containing a set of instructions that can be called from other parts of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

definite iteration:

A

-loop repeats for a specific number of times

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

indefinite iteration:

A

-block of code only repeats as long as the condition is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

nesting:

A

-when one structure is placed within another to create a more complex structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

arithmetic operations:

A

-addition
-subtraction
-multiplication - *
-division - /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

relational operations:

A

-used to compare 2 values
-equal to - ‘=’
-not equal to - ‘!’
-less than - ‘<’
-greater than - ‘>’
-less than or equal to - ‘<=’
-greater than or equal to - ‘>=’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

boolean operations:

A

-NOT ,, ! , opposite of a boolean value
-AND ,, && , product of 2 boolean values
-OR ,, ||, sum of 2 boolean values
-XOR - true if only one of 2 values is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
variables
can change the value during the execution of a program
26
constants
value cannot be changed once assigned
27
advantages of using constants
-can be given identifier names making it easier for a human to understand -when updating a value constants only need updating once
28
string handling operations:
-length -position -sub string -concatenation -character to character code -character code to character -string to integer -string to float -integer to string -float to string
29
length:
returns the number of characters in a specified string
30
position:
returns the position of a specified character within a string
31
sub string:
given a starting position and a length so returns the portion of a string
32
concatenation:
joining 2 or more string together to form a new longer string
33
character to character code:
returning the character code which corresponds to a specified character
34
character code to character:
returning the character represented by a given character
35
random number generation:
-built in function takes a value and uses a series of mathematical operations to arrive at a number
36
exception
thrown when a error occurs in a program code
37
parameters
used to pass data between subroutines within programs , specified within brackets after a subroutine is called
38
local variables
variable that can only be accessed from the subroutine within which it is declared
39
==
compare 2 value sin a condition
40
global variables
can be accessed from any part of the program
41
=
assigning a value
42
+=
increases a variable by a set amount
43
-=
decreases a variable by a set amount
44
for loops
have a start and end
45
creating a record
-define the record structure , what fields will be in it -declare variable or array to use with the record -assign and retrieve data from the variable record
46
while loop
can loop forever
47
array
allows us to store multiple variables of the same type under a single identifier
48
record
way of storing multiple variables under a single identifier
49
string manipulation
way of scanning, checking , updating , converting strings in various ways
50
subroutine
-block of code given a unique, identifiable name within a program
51
procedure
-takes in zero, one or more parameters and performs a set task
52
function
-block of code that takes in zero,one or more parameters -returns a value
53
advantages of using subroutines:
-programs are easier to write -programs are easier to debug -functions can be grouped into libraries for easy reuse across multiple programs -programs are easier to test
54
parameter
named variable defined in a function or method signature that acts as a placeholder for input data
55
local variables:
-usually declared inside subroutines -accessible by only that subroutine -created when the subroutine is called -destroyed when subroutine ends
56
global variables:
-declared at the top of the program outside of any subroutine usually -accessible throughout the program -created when program starts -destroyed when program ends
57
stack frame
- stores all essential information for a single subroutine -allows program to know where to return to -allows programto restore the values of any local variables and parameters when it returns
58
before calling another subroutine the system needs to:
-construct a stack frame -add a return address to the stack frame -add any local variables to the stack frame -push the completed stack frame on to the stack
59
recursion
when a subroutine calls itself from within its own subroutine
60
recursive subroutine should :
-contain a stopping condition (base case) -for any input value other than the stopping condition the subroutine should call itself(recursion) -stopping condition should be reachable within a finite number of times
61
factorial of a number:
-for a positive number it is the product of all the positive integers less than or equal to n -n! -e.g. 5! =5 x 4 x3 x 2 x 1 =120
62
paradigm
example of a way of doing things
63
types of imperative languages:
-procedural programming -object orientated programming
64
procedural programming
-where a program is built from one or more subroutines
65
object orientated programming
-based on organising software design around objects rather than functions
66
procedural programming details:
-features include sequence, selection and iteration -data is stored in local or global variables and can be accessed by other parts of program without passing a parameter -structure included procedures and functions -program logic is expressed in a series of procedure calls
67
object oriented programming details:
-features consist of sequence, selection, iteration, inheritance, classes , objects , encapsulation -data is stored in attributes and concealed from other parts of the program via encapsulation -program structure consists of classes, methods and instances -program logic is based on models and behaviours
68
problem decomposition:
-taking a large problem and breaking it down into several smaller problems
69
step wise refinement/top down modular design:
-way to tackle problem decomposition
70
advantages of having a structured approach :
-program is easier to read and understand -reduces the chance of errors and bugs as each function can be tested individually -changes can be made to one function without affecting others -enhances productivity and efficiency for programmer -improves reusability of the program as functions can be reused for different purposes
71
object oriented programming(OOP):
-attempts to group information,data or related code into structured items known as objects
72
objects - OOP:
-responsible for its own data and operations performed on that data -interact with each other by sending or receiving messages
73
sections of classes:
-name of class -attributes of the class -methods of the class
74
attributes - OOP:
- variables belonging to an object or class and containing information about their properties or characteristics
75
methods-OOP:
-a procedure associated with the class that allows you to access or change its attributes
76
class:
-a blueprint or template used to create specific objects
77
instantiation:
-process of creating a object from a class template, where each object has its own attributes, methods and class template -when a object is created constructor sets up the new object and takes the values you give it and stores them inside the object
78
constructor method:
-designed to initialise a new object instance when it is created
79
inheritance:
-where a new class (child class) is derived from a existing class (parent class), inheriting its attributes and methods
80
benefit of inheritance:
-can quickly and easily reused the code from the parent class and extend its attributes and methods without affecting the original code
81
overriding:
-when you call a method from a object that shares the same name as a method further up the class tree
82
encapsulation
-bundles the attributes and methods and restrict direct access to them -used to hide values or the internal state of a object, preventing direct access from unauthorised parties -helps keep data related to a object safe
83
polymorphism:
situations in which something occurs in several different forms
84
2 main types of polymorphism:
-static -dynamic
85
static polymorphism:
-allows you to implement multiple methods of the same name but with different parameters within the same class
86
static polymorphism, parameter sets must differ in at least one of these:
-different number of parameters -types of parameters need to be different -need to expect the parameters in a different order
87
dynamic polymorphism:
-within a inheritance hierachy, a subclass can override a method of its superclass, enabling the developer of the subclass to customise or replace the behaviour of that method
88
association
-relationship between two separate classes where one class uses or interacts with another
89
aggregation
-more specific form of association -class contains or has many other classes, but those other classes can exist independently of the main class.
90
composition
-stronger form of association -contained classes have a strong dependency on container class as if it is destroyed all container classes are too
91
3 design principles of object orientated programming:
-favour composition over inheritance -encapsulate what varies -program to a interface not implementation
92
why favour composition over inheritance:
-allows for greater flexibility -its less rigid than relationships that exist under inheritance -a object may be made of several other objects but in real life it does not make sense to say its inherited its characteristics
93
why encapsulate(sum up) what varies:
-reduces need for testing and maintenance -designers should take properties and methods and sub divide them into as many classes as required to reflect real life scenarios
94
why program to a interface not implementation:
-focus on what the code is doing instead of how its doing it -can change things more easily -code is more reusable
95
interface
-declaration of capability -no actual code implemented