Search Header Logo
20 Further Programming

20 Further Programming

Assessment

Presentation

Computers

10th Grade

Practice Problem

Easy

Created by

ZUKO NDABAMBI

Used 2+ times

FREE Resource

24 Slides • 53 Questions

1

20 Further Programming

20.1 Programming Paradigms

20.2 File Processing and Exception Handling

2

Open Ended

Describe what is meant by an imperative (procedural) programming language. (2)

3

Describe what is meant by an imperative (procedural) programming language.

One mark for each correct marking point (Max 2)

  • Imperative languages use variables

  • ...which are changed using (assignment) statements

  • ...they rely on a method of repetition / iteration.

  • The statements provide a sequence of commands for the computer to perform

  • ...in the order written / given

  • ...each line of code changes something in the program run.

4

Open Ended

Describe what is meant by a declarative programming language.(2)

5

Describe what is meant by an imperative (procedural) programming language.

One mark for each correct marking point (Max 2)

  • Instructs a program on what needs to be done instead of how to do it

  • ... using facts and rules

  • … using queries to satisfy goals.

  • Can be logical or functional

  • Logical - states a program as a set of logical relations

  • Functional – constructed by applying functions to arguments / uses a mathematical style

6

Multiple Choice

Question image

Identify the programming paradigm for the program code example (see image).

1

Declarative

2

Procedural / imperative

3

Low-level / assembly

4

Object oriented / (OOP)

7

Multiple Choice

Question image

Identify the programming paradigm for the program code example (see image).

1

Declarative

2

Procedural / imperative

3

Low-level / assembly

4

Object oriented / (OOP)

8

Multiple Choice

Question image

Identify the programming paradigm for the program code example (see image).

1

Declarative

2

Procedural / imperative

3

Low-level / assembly

4

Object oriented / (OOP)

9

Multiple Choice

Question image

Identify the programming paradigm for the program code example (see image).

1

Declarative

2

Procedural / imperative

3

Low-level / assembly

4

Object oriented / (OOP)

10

Fill in the Blank

Question image

State the addressing mode used by

LDM.

11

Fill in the Blank

Question image

State the addressing mode used by

LDD

12

Open Ended

Question image

Using opcodes from the table, write instructions to set the value at address 509 to the contents of address 500 added to the value 12.

13

Using opcodes from the table, write instructions to set the value at address 509 to the contents of address 500 added to the value 12.

One mark for each correct marking point (Max 2)

  • LDM #12 [1]

  • ADD 500 [1]

  • STO 509 [1]

14

Open Ended

Describe what is meant by the term properties

15

Describe what is meant by the term properties

One mark for each correct marking point (Max 2)

  • the data items / attributes

  • the data types // characteristics

  • defined in a class

16

Open Ended

Describe what is meant by the term methods

17

Describe what is meant by the term methods

One mark for each correct marking point (Max 2)

  • the procedures/ functions / programmed instructions in a class / super class / base class

  • … implementing the behaviours

  • … that act on the properties / attributes

18

Open Ended

Describe what is meant by the term inheritance

19

Describe what is meant by the term inheritance

One mark for each correct marking point (Max 2)

  • Methods and properties / attributes contained in one class/ super class / base class

  • Are made available to / reused by another class/ derived class

20

Fill in the Blank

Question image

Write the declaration in pseudocode for OwnerName as PRIVATE.

21

Open Ended

Question image

Explain why the properties have been set to PRIVATE

22

Explain why the properties have been set to PRIVATE

To ensure that attributes can only be accessed by the class’s own methods

To enforce encapsulation // ensure they are hidden

23

Fill in the Blank

Question image

More facts are to be included. Sam studies history and Nina is his tutor.

Write the additional clauses to record these facts.

18.

24

Fill in the Blank

Question image

More facts are to be included. Sam studies history and Nina is his tutor.

Write the additional clauses to record these facts.

19.

25

Fill in the Blank

Question image

Write the result returned by the goal:

studies(Student, geography)

studies(Student, geography) = .................

26

Open Ended

Question image

Write the goal, using the variable X, to find all the students who have a tutor that teaches them. For example, Hua has Alan for a tutor and is also taught mathematics by Alan

27

Explain why the properties have been set to PRIVATE

one mark for correct use of X

one mark for two other variables in correct positions

one mark for three correct clauses in any order

one mark for correct syntax

teaches(R, S),

studies(X, S),

tutors(R, X).

28

Open Ended

State the reasons for including exception handling routines when writing a program. Include an example of an exception in your answer. (4)

29

Explain why the properties have been set to PRIVATE

To trap (some) runtime errors

To prevent a program halting unexpectedly

To produce meaningful error messages for these errors

Example divide by zero // end of file // file not found

30

Fill in the Blank

Question image

The address 500 contains the value 100 and the address 100 contains the value 20.

State the contents of ACC after the following instruction has been executed.

LDM #500

31

Fill in the Blank

Question image

The address 500 contains the value 100 and the address 100 contains the value 20.

State the contents of ACC after the following instruction has been executed.

LDD 500

32

Fill in the Blank

Question image

The address 500 contains the value 100 and the address 100 contains the value 20.

State the contents of ACC after the following instruction has been executed.

LDI 500

33

Multiple Choice

Programs using the instruction set of a processor

1

Low-level

2

Object oriented

3

Imperative

4

Declarative

34

Multiple Choice

Programs using the concepts of class, inheritance, encapsulation and polymorphism

1

Low-level

2

Object oriented

3

Imperative

4

Declarative

35

Multiple Choice

Programs with an explicit sequence of commands that update the program state, with or without procedure calls

1

Low-level

2

Declarative

3

Imperative

4

None

36

Multiple Choice

Programs based on events such as user actions or sensor outputs

1

Low-level

2

Declarative

3

Imperative

4

None

37

Open Ended

Define these Object-Oriented Programming (OOP) terms (3):

a) Instance

b) Inheritance

c) Polymorphism

38

Define these Object-Oriented Programming (OOP) terms:

  • Instance – an occurrence of an object // a specific object based on the class // an instantiation of a class.

  • Inheritance – the capability of defining a new class of objects that has all the attributes and methods from a parent class.

  • Polymorphism – allows the same method to take on different behaviours depending on which class is instantiated // methods can be redefined for derived classes.

39

Fill in the Blank

Question image

Write down answer for number 1

40

Fill in the Blank

Question image

Write down answer for number 2

41

Fill in the Blank

Question image

Write down answer for number 3

42

Fill in the Blank

Question image

Write down answer for number 4

43

Fill in the Blank

Question image

Write down answer for number 5

44

Fill in the Blank

Question image

Write down answer for number 6

45

Fill in the Blank

Question image

Write down answer for number 7

46

Open Ended

Define these Object-Oriented Programming (OOP) terms (3):

a) Encapsulation

b) Getter

c) Setter

47

Define these Object-Oriented Programming (OOP) terms:

One mark for each correct OOP term definition

  • Encapsulation – putting properties and methods inside a class // ensures sensitive data is hidden from users by hiding values of a structured data object inside a class.

  • Getter – method that is used to return the value of a property.

  • Setter – method that is used to update the value of a property.

48

Fill in the Blank

Question image

Write down answer for number 1

49

Fill in the Blank

Question image

Write down answer for number 2

50

Fill in the Blank

Question image

Write down answer for number 3

51

Fill in the Blank

Question image

Write down answer for number 4

52

Fill in the Blank

Question image

Write down answer for number 5

53

Open Ended

Question image

Write assembly language instructions to set the contents of addresses 601 and 602 to zero, and set all four least significant bits of the contents of address 603 to one. Use the instruction set from Table 8.1 (3)

54

Write assembly language instructions

1 mark per bullet point

  • Storing 0 in 601 and 602

  • Loading the correct pattern for 603

  • … Storing in 603

    LDM &00 /#0 / B00000000

    STO 601

    STO 602

    LDM B00001111 /#15 /&0F

    STO 603

55

Open Ended

Carlos is writing exception handling code for his program.

(a) State what is meant by an exception.(1)

56

) State what is meant by an exception.

It is an unplanned event // an event not wanted

57

Open Ended

Carlos is writing exception handling code for his program.

Give three situations where an exception handling routine would be required.(3)

58

Give three situations where an exception handling routine would be required.

1 mark per example to max 3 e.g.

  • Division by zero

  • Invalid array index

  • File does not exist

  • Run-time error

  • Invalid input

  • Invalid argument/value

  • Stack overflow

  • Memory leakage

  • Hardware failure/error

59

Open Ended

Carlos is writing exception handling code for his program.

Describe the benefits of using exception handling in a program.(2)

60

Describe the benefits of using exception handling in a program.(2)

mark per bullet point to max 2

  • The program will not crash // more robust // program will continue

  • Result does not cause further errors/problems later

  • Appropriate error messages/result

  • Exceptional conditions are identified

  • Improve readability

61

Open Ended

Question image

Elle is a person who plays rugby but refuses to play hockey. Write additional clauses to represent this information. (4)

62

Write additional clauses to represent this information. (4)

1 mark for each statement

  • person(elle).

  • sport(rugby).

  • plays(elle, rugby).

  • will_not_play(elle, hockey)

63

Fill in the Blank

Question image

Elle is a person who plays rugby but refuses to play hockey. Write the result returned by the goal: plays(X, football).

64

Open Ended

Question image

Elle is a person who plays rugby but refuses to play hockey. Y might play X, if Y is a person, X is a sport and Y does not refuse to play X.

Write this as a rule.

mightplay(Y , X)

65

Write additional clauses to represent this information. (4)

1 mark per bullet point

  • person(Y)

  • AND // ,

  • sport(X)

  • AND NOT // , NOT

  • will_not_play(Y, X)

    mightplay(Y, X)

    IF person (Y) AND sport (X) AND NOT(will_not_play(Y, X))

66

Open Ended

Object-oriented programming has several features. These include inheritance, classes, methods and properties

Identify two other features of object-oriented programming.

67

Identify two other features of object-oriented programming.

1 mark per feature to max 2

  • Polymorphism

  • Encapsulation

  • Containment

  • Aggregation

  • Composition

68

Open Ended

OWrite program code for the Constructor() method. Use the appropriate constructor method for your chosen programming language

69

Identify two other features of object-oriented programming.

def init(self, LType, LInstructor) :

self.__ LessonType = LType

self.__Instructor = LInstructor

70

Open Ended

Write program code for the GetLessonType() method

71

IWrite program code for the GetLessonType() method

1 mark per bullet point

  • function header and close (where applicable)

  • returns Fee

    def GetLessonType(self) :

    return self.__LessonType

72

Open Ended

Question image

Write program code for the GetFee() method

73

Write program code for the GetFee() method

1 mark per bullet point

  • Function header and close (where applicable)

  • Takes a parameter value

  • Check parameter value is valid …

  • … returns the correct fee

  • Returns -1 if value not valid

    PYTHON

    def GetFee(self, Level) :

    if Level == 'B' : return 45

    elif Level == 'I' : return 50

    elif Level == 'A' : return 55

    else : return -1

74

Open Ended

Question image

Write program code for the GetLessonType() method

75

Write program code for the GetLessonType() method

1 mark per bullet point

  • Array declaration with identifier LessonArray and size 9

  • Correct data type used

    DECLARE LessonArray : ARRAY[0:8] OF Lesson

76

Open Ended

Question image

The tennis club has the lesson ‘Improve Your Serve’ that has David as the instructor.

Write program code to create the lesson ‘Improve Your Serve’ as an instance of the class Lesson. The object needs to be stored in the third element of the array LessonArray

77

Write program code for the GetLessonType() method

1 mark per bullet point

  • Object is created

  • Correct parameters passed

  • Stored in correct index of LessonArray

    PYTHON

    LessonArray[2] = Lesson("Improve Your Serve", "David")

20 Further Programming

20.1 Programming Paradigms

20.2 File Processing and Exception Handling

Show answer

Auto Play

Slide 1 / 77

SLIDE