UNIT 11: Programming Techniques Flashcards

1
Q

What does IDE stand for?

A

Integratred Devlopoment Enviroment

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

facilities of an IDE

A

Integratred Devlopoment Enviroment is a software which enables you to enter, edit, compile (or interpret) and run your programs

many IDE’s will alos have debugging faciliites to help you find the logic errors in a program

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

Features of an IDE

A

add line numbers

automatically ident code

auto-complete commands

comment of run-comment a region

finding syntax errors

finding logic errors

debugging facilities

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

debugging facisilities

A

set a breakpoint (cause the program to stop on that line)

set a watch on a variable so that its value is displayed each time it changes

step through a program one line a time

trace the execution of a program for example display a mesage every time a particular statement is executed or subroutine is called

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

algorithm defintion

A

an algorithm is a sequence of instructions that can be followed to solve a problem

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

pseudocode defintion

A

pseudocode is used to write instructions in statements that are somewhere between english and a programming language

guidelines for writing pseudocode no strict rules tho

its an aid

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

variable and assignment

A

identifier is a name. eg score that points to a memeory location

assignemnet is assigning a value to the memory location

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

varaibles and constants

A

value of a variable can be changed

to change the value of a constant you have to change it in the source code and then recompile

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

why use a constant

A

reduce the risk of errors by reducing access to the mmeory location

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

mod and div operators

A

mod is REMINADER

div is just division

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

if then endif - - - - - - program flow

A

program flow is controlled by evaluating a boolean condition

boolean condition evaluates to true or false

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

relational operators

A

> greater than
< less than
=> greater than or equal to
=< less than or equal to
== equal too
!= not equal too

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

complex boolean expressions§

A

AND returns TWUE is both conditions are true
OR returns TRUE is either of the conditions is true
NOT a TRUE expressions becomes FALSE vice versa

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

if then elseif else endif

A

if aljdkja;dka

elseif sadfjalskfja

else lasjfkads

endif

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

switch/case .. endswitch

A

logical equivalent of the
if then else endif statement

switch choice

case a ksldfa;jsdfkja
case b saldjfldas
case c asdlkfjad
default asdlkfja;dkfjs
endswitch

PYTHON NO doesnt have this

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

nested if

A

in the nested if statement, the second conditioin is only checked if the first condition is true

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

iteration

A

means repetition

a sequence of instructions is repeated multiple times

this is much more efficient than writing the instructions mulitple times

the number of repetitions needed may vary and may not be known when writing the code

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

while endwhile loop

A

condiiton is tested upon entry to the loop

its possible that the instructions inside the loop might not be executed at all if the entry condition is not met

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

do until loop

A

statements in the loop are excuted before the condition is evaluated
not in python
equgialent is while.. end while loop

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

infinite loop

A

you may make one if u make a damn error

brief pause can be included to slow down the loop

computer xontrol and data sendsing appliocations use infinite loops to gather data from sensors

  • varitety of sensors can control a number of output dvices such as lights, buzzers and motors
  • after the setup code is run the device enters an infiinite loop to repeatedly check the value of the sensors.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

for.. next loop

A

termed ‘definite iteration’ and is used to repeat a block of insturctions a specififed number of times

uses a counter variable which is automatically incrememnted each time through the loop

optionally a step value can be specified to make the counter increase or decrease by any integer

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

nested for .. next loop

A

it is possible to use nested for loops

useful for looping through grids in two dimensional arrays

22
Q

subroutine

A

set of instructions with a name

23
Q

built in functions

A

programming lanugages come with many built in functions which perform common tasks

24
library subroutines
programming languages also come complete with libraries of pre-defined subroutines the module library has to be imported at the start of the program import random ahh subroutine import
25
passing arguments
arguments in parentheses are used to pass data into a subroutine procedure multiply(x,y)
26
parameters and arguments
both terms are used interchangeably strictly speaking, parameters appear in subroutine definitions, and arguments appear in subroutine calls parameter (x,y) argument - when called
27
passing by value
in python all arguments are passed by value means that the actual value of the argument in the calling statement is copied to the variable parameter in the subroutine any calc perfomred on that parameter in the subroutine will not affect the value of the corresponding argument in the calling routine
28
passing by refrence
some programming languages allow arguments to be passed by value or by reference by reference means that the address of the argument in the calling statement is passed to the corresponding parameter in the subroutine any caluculation perfomred on the parameter in the subroutine will change the value of the corresponding argumnet in the calling routine
29
variable scope
determines where a variable can be accessed within a program
30
local variables
a subroutine may have its own variables local variable can only be used in that subroutine
31
global variables
defined in the main perogram and can be used in any subroutine called from the main program
32
scope of variables (local and global)
scope of a local variable is the subroutine in which it is declared global is everywhere duh
33
advantages of local variables
subrroutines will be indepdnet of a particular program and can be reused else where no chance of accodenetally changing a variable in the main program that is used in a subroutine or vice versa
34
modular programming
means breaking down a major task into smaller subtasks these subtasks may be further broken down until each module performs a singular function
35
advantages of modular programming
programs are more easily and quickly written large programs are broken down into subtasks that are easier to program and manage each module can be individually tested modules can be re-used several times in a program large programs are much easier to debuh and maintain
36
factorials
5! (5 factorial) 5x4x3x2x1
37
recursion
factorial function is a good example of a function that can be defined in terms of itself n! = n x (n-1)!
38
essential characteristics or a recusive routine (3 of them)
a stopping condition or BASE CASE must be included which when met meanas that the routine will not call itself and will start to unwind for input values other than the stopping condition, the routine must call itself the stopping condition must be reached after a finite number of calls
39
stack overflow!
occurs when a computer program tries to use more memory space in the call stack than has been allocated to that stack.
40
use of the call stack
every time a subroutine is called, the return address (line after call statement) is put on the call stack even with a stopping condition the recusive routine can only be called a limited number of times or the stack will overflow the maxium memory capcity
41
recursive fibonacci (more info)
each number is found by adding the two precceeding numbers
42
recursive vs iterative routines
recursive can casue stack overflow recusrive usually have fewer lines iteerative is easier to follow iterative geenrally exccute faster iterative is more faster usually
43
OOP
object oriented programmiing
44
classes - OOP
class is a blueprint for an object it defines what an object in the class will look like (its properties) and what it can do A class may implement an abstract data type such as an array or fraction or a more concrete object such as a person or car
45
attributes and methods - OOP
class will define the attributes of objects in the class it will also define methods (procedures) that an object in the class can perform
46
public and private - OOP
attributes are normally declared as private methodds are public usually this is to ensure that attributes cannot be changed except by executing a method
47
encapsulation and data hiding
enca[psulation wraps the attributes and methods in the class defintiiotn hiding details of the implementation from the user
48
setter and getter methods
we often need a means to set an attribute or to find out the value of an attribute data hiding - means programmer who dfines an object in a class cannot directly access or change an attribute of an object it has to be done via a getter or setter method
49
inheritance
ability to define child classes which inherit the attributes and methods of a parent class arrows always towards the parent class
50
polymorphism
inherited class may redefine methods that are defined in the parent class ability of a programming language to process objects differently depdning on their class is called polymorphism
51
advantages of OOP
code reuse - classes created in one program can esasily be saved to a library and resused in other programs - leads to faster program development encapsuslation reduces code completxity - once an object is created it is not necessary to know how its methods are implrmenented, attirubutese can be hidden from useres so that they cant change them accidentally software maintenace - easay to modify and maintain
52