20 - further programming (pyhton files) Flashcards

1
Q

programming paradigm

A

set of programming concepts
eg low level, imperative, object oriented, declarative

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

OOP

A

programming methodology that uses self contained objects containing programing statments and data that communicate with each other

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

class

A

defines the methods and data of a certain type of object

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

attributes

A

data items in a class

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

method

A

a programmed procedure which is defined as part of a class

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

encapsulation

A

process of putting data and methods together as a single unit, a class

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

object

A

an instance of a class that is self-contained and includes data and methods

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

property

A

data and methods within an object that perform a named action

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

instance

A

An occurrence of an object during the execution of a program

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

data hiding

A

technique which protects the integrity of an object by restricting access to the
data and methods within that object
__ makes attributes private in python so need getters to retrieve attributes

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

inheritance

A

process in which the methods and data from one class, a superclass or base class, are copied to another class - a derived class

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

polymorphism

A

feature of object-oriented programming that allows methods to be redefined for derived classes

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

overloading

A

feature of object-oriented programming that allows a method to be defined more than once in a class, so it can be used in different situations

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

containment

A

a relationship in which one class has a component that is of amnother class type
one class contained in another type

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

getter

A

a method that gets the value of a property

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

setter

A

a method used to control changes to a variable

17
Q

constructor

A

a method used to initialise a new object

18
Q

destructor

A

a method that is automatically invoked when an object is destroyed

19
Q

declarative programming

A

statements of facts (a thing thats known) and rules (relationships between facts) together with a mechanism for setting goals in the form of a query

20
Q

defining a class in python

A

class person ():
def __init__ (self, name, age)
self.__name = name
self.__age = age
def GetName(self):
return self.__name
def GetAge(self):
return self.__age

21
Q

setting up an instance of an object

A

thisperson = person(“bob”, 20)

22
Q

inheritance - derived class python

A

class employee(person):
def __innit__(self, name, age):
person.__init__(self, name, age)
self.__hours = 0
def GetHours(self)
return self.__hours

23
Q

polymorphisim in python

A
24
Q

python overloading

A

class greeting():
def hello(self, name = None):
if name is not None
print(“Hello” +name)
else:
print(“Hello”)

thisgreeting = greeting()
thisgreeting.hello()
(when no parameters it just prints hello)
thisgreeting.hello(“bob”)
(when there is a parameter it prints hello name)

25
Q

setter python

A

def SetName(self, name):
self.__name = name

26
Q

getter python

A

def GetName(self):
return self.__name

27
Q

destructor python

A

def __del__(self):
print(“deleted”)

28
Q

exception handling

A

responding to an exception within the program so that the program doesnt stop unexpectedly

29
Q

storing records in a sequential file

A
30
Q

opening a file pyhton

A

f = open(‘filename’ , ‘r’)
‘r’ is read
‘a’ is append
‘w’ is write

31
Q

exception handling in python

A

try:

<statement>
except <error>:
print('error')
</error></statement>

32
Q

+ OOP

A

+ produces robust, more reliable code - attributes can only be manipulated using methods - protected from accidental change
+ classes provided in module libraries are thoroughly tested

33
Q

serial files

A

contains records that have not been organised in an order

34
Q

sequential files

A

has ordered records

35
Q

imperative programming paradigm

A

writing a program as a sequence of explicit steps that are executed by the processor

36
Q

object oriented programming paradigm

A

based on objects interacting with one another objects are data structures with associated methods

37
Q

declarative programming paradigm

A

writes down a specification that describes what th eproblem is not what the computer should do - sets up queries for the programming system to decide what to do with eg SQL

38
Q

low level programming paradigm

A

gives us the ability to manipulate contents of meory and registers directly and exploit the architecture of a given processor

39
Q

random files

A

a file that stores records at specific addresses that can be accessed directly (direct access storage)