Programming Paradigms (Cambridge (CIE) A Level Computer Science): Exam Questions

Exam code: 9618

34 mins4 questions
1a3 marks

A declarative programming language is used to represent the features that are available and the features that are unavailable on different body styles of a car.

01 feature(sunroof).

02 feature(automatic_tailgate).

03 feature(heated_seats).

04 feature(extra_seats).

05 feature(reversing_camera).

06 feature(dashboard_camera).

07 feature(air_conditioning).

08 feature(heated_windscreen).

09 feature(satnav).

10 bodystyle(saloon).

11 bodystyle(hatchback).

12 bodystyle(estate).

13 bodystyle(minivan).

14 bodystyle(convertible).

15 available(sunroof, hatchback).

16 available(sunroof, minivan).

17 available(reversing_camera, hatchback).

18 available(extra_seats, minivan).

19 available(reversing_camera, saloon).

20 unavailable(sunroof, convertible).

21 unavailable(automatic_tailgate, saloon).

22 unavailable(extra_seats, hatchback).

These clauses have the meanings:

Clause

Meaning

01

Sunroof is a feature.

10

Saloon is a body style.

15

Sunroof is available on a hatchback.

20

Sunroof is unavailable on a convertible.

Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.

Write additional clauses to represent this information.

23........................................................................

24........................................................................

25........................................................................

1b1 mark

Using the variable Options, the goal:

available(Options, saloon)

returns

Options = reversing_camera

Write the result returned by the goal:

available(Options, hatchback)

Options = ........................

1c4 marks

F may be available for B if F is a feature and B is a body style and F is not unavailable for that body style.

Write this as a rule:

may_choose_option(F, B)

IF .........................................

2a4 marks

A declarative programming language is used to allow clients to choose daily activities at the beach.

01 activity(paddleboarding).

02 activity(sailing).

03 activity(rowing).

04 activity(kayaking).

05 activity(jetskiing).

06 client(stevie).

07 client(antonio).

08 client(henry).

09 client(eliza).

10 client(rebeka).

11 client(danny).

12 client(erik).

13 client(simone).

14 client(petra).

15 client(frankie).

16 choice(petra, rowing).

17 choice(frankie, sailing).

18 choice(erik, sailing).

19 choice(eliza, rowing).

20 choice(stevie, jetskiing).

21 choice(henry, sailing).

22 done(henry, jetskiing).

23 done(rebeka, jetskiing).

24 done(antonio, kayaking).

These clauses have the meanings:

Clause

Meaning

01

Paddle boarding is an activity

06

Stevie is a client.

16

Petra has chosen rowing

22

Henry has already done jet skiing.

Jane is a client who would like to choose the activity surfing and she has already done sailing.

Write additional clauses to represent this information.

25 ...............................................................

26 ...................................................................

27..................................................................

28 ...............................................................

2b1 mark

Using the variable List, the goal:

choice(List, rowing)

returns

List = petra, eliza

Write the result returned by the goal:

choice(List, sailing)

List = ................................

2c4 marks

C is a client who would like to choose A if A is an activity and C has not already done A.

Write this as a rule:

may_choose_activity(C, A)

IF ............................................

3a3 marks

A declarative programming language is used to represent subjects that students can choose to study.

Students must choose two subjects

01 subject(mathematics).

02 subject(physics).

03 subject(chemistry).

04 subject(computer_science).

05 subject(geography).

06 subject(history).

07 subject(english).

08 subject(biology).

09 student(tomaz).

10 student(josephine).

11 student(elspeth).

12 student(nico).

13 student(teresa).

14 student(pietre).

15 choice1(tomaz, mathematics).

16 choice1(teresa, chemistry).

17 choice1(pietre, mathematics).

18 choice1(nico, mathematics).

19 choice1(elspeth, chemistry).

20 choice2(tomaz, computer_science).

21 choice2(nico, geography).

These clauses have the meanings:

Clause

Meaning

01

Mathematics is a subject.

09

Tomaz is a student.

15

Tomaz has chosen mathematics as his first choice.

20

Tomaz has chosen computer science as his second choice.

Anthony is a student who would like to study history and geography.

Write additional clauses to represent this information.

22 ...........................................

23 ..........................................

24 ...........................................

3b1 mark

Using the variable X, the goal:

choice1(X, chemistry)

returns

X = teresa, elspeth

Write the result returned by the goal:

choice1(X, mathematics)

X = .................

3c4 marks

Students must choose two different subjects such that:

N may choose S, if N is a student and S is a subject and N has not chosen S as the first choice.

Write this as a rule.

may_choose_subject(N, S)

IF .............................

4a4 marks

A declarative programming language is used to represent some facts about people and their hobbies.

01 hobby(music).

02 hobby(caving).

03 hobby(climbing).

04 hobby(camping).

05 hobby(baking).

06 hobby(travelling).

07 person(toby).

08 person(natasha).

09 person(fatima).

10 person(joseph).

11 person(elijah).

12 person(nina).

13 enjoys(natasha, travelling).

14 enjoys(toby, climbing).

15 enjoys(nina, climbing).

16 enjoys(elijah, camping).

17 enjoys(fatima, baking).

18 enjoys(joseph, camping).

19 dislikes(toby, caving).

These clauses have the meanings:

Clause

Meaning

01

Music is a hobby

07

Toby is a person

13

Natasha enjoys travelling

19

Toby dislikes caving

Carlos is a person who enjoys the hobby of cycling but does not like music.

Write additional clauses to represent this information.

20...........................

21...........................

22...........................

23...........................

4b1 mark

Using the variable P, the goal:

enjoys(P, camping)

returns

P = elijah, joseph

Write the result returned by the goal:

enjoys(P, climbing)

P = ....................

4c4 marks

N is a person who might enjoy H if H is a hobby and N does not dislike H.

Write this as a rule.

might_enjoy(N, H)

IF .........................