wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Midterm Exam - CSCI0823

Total questions: 50

Worksheet time: 38mins

Name
Class
Date
1.

Suppose that we have the following facts in student.pl

eats(leeminho, bbq).

eats(leeminho, oats ).

eats(leeminho, salad).

Identify the objects in the above facts

a)

leeminho, salad

b)

oats, bbq

c)

Both a and b

d)

None of the above

2.

Assert the statement,

Jin is a friend of james.

a)

assert(friend(jin,james)).

b)

assert(friend(james,jin)).

c)

ERROR: Undefined procedure

d)

invalid predicate

3.

Interpret the given code

write(15),write( ' plus '),write(10),write(' is ' ), X is 15+10 ,write(X),nl.

a)

15 plus 10 is 25, X = 25

b)

15 + 10 is 25, X = 25

c)

15 plus 10, X = 25

d)

X = 15 plus 10 is 25

4.

Compare one of Prolog’s defining features, Prolog is a ____ language

a)

declarative rather than a procedural

b)

procedural rather than a declarative

c)

declarative and procedural

d)

None of the above

5.

Assess that Prolog arithmetic follows MDAS

a)

True

b)

False

c)

Only when using exponent

d)

Both a and c are correct

6.

Use the following for the database.assert(), identify the predicate symbol

parent(hank,ben).

parent(irene,ben).

parent(hank,denise).

parent(irene,denise).

a)

parent

b)

irene, hank

c)

ben, denise

d)

hank

7.

Name the developer of the first Prolog interpreter

a)

Phillipe Roussel

b)

Phillipe Rousel

c)

Phillipe Rousell

d)

Phillipe Rossel

8.

Compose the query to determine the parent in the given database

parent(hank,ben).

parent(irene,ben).

parent(hank,denise).

parent(irene,denise).

a)

?- parent(X,_).

b)

?- parent(X,ben).

c)

?- parent(_,_).

d)

?- parent(X).

9.

Discover the variable in the given instance

write(Top+Middle+Bottom),nl,fail.

a)

Top

b)

Middle

c)

Bottom

d)

All of the above

10.

Suppose that we have the following facts in exam.pl

likes(fred,pears).

likes(fred,t_bone_steak).

likes(fred,apples).

Analyze the use of fred

a)

object

b)

variable

c)

Both a and b

d)

Predicate symbol

11.

Using Prolog arithmetic, solve for

?- 5 is 6 -1.

a)

true

b)

false

c)

5

d)

X = 5

12.

Prolog contains facts and rules. Inspect the facts in the following:

eats(loren,apple).

long_hair(miley).

a)

Both given are facts

b)

loren, apple

c)

miley

d)

eats and long_hair

13.

Prolog answered “true” in the given query. Interpret the use of ASSERT function in the given statement

?- midterm_exam.

true.

a)

?- assert(midterm_exam.).

b)

?- assertz(midterm_exam.).

c)

Assert(midterm_exam.).

d)

Asserta(midterm_exam.).

14.

Formulate the children of hank and irene in the database below

parent(hank,ben).

parent(irene,ben).

parent(hank,denise).

parent(irene,denise).

a)

?- parent(_,Children).

b)

?- parent(X,ben).

c)

?- parent(X,denise).

d)

?- parent(Children).

15.

In the beginning of the given database,

parent(hank,ben).

parent(irene,ben).

parent(hank,denise).

parent(irene,denise).

Add

parent(hank,leo)

as the last statement

a)

assertz(parent(hank,leo)).

b)

asserta(parent(leo,hank)).

c)

retract(parent(hank,leo)).

d)

assert(parent(hank,leo)).

16.

Match the English interpretation of

?-friend(nadine, james).

a)

Nadine is a friend of James.

b)

James is a friend of Nadine.

c)

Nadine and James are friends.

d)

None of the above

17.

Infer the result of

?- assert(csci0823(midterm,exam)).

a)

True

b)

False

c)

csci0823(midterm,exam).

d)

Unknown Predicate

18.

Extend the cause of error in line number

?- [parent_db.txt].

ERROR: Syntax error: Operator expected

a)

No single quotes

b)

No double quotes

c)

The extension name must be .pl

d)

The use of underscore

19.

Refer to the given database

parent(hank,ben).

parent(irene,ben).

parent(hank,denise).

parent(irene,denise).

Choose the cause of error in line number

9 ?- parent(Parents).

ERROR: Undefined procedure: parent/1

ERROR: However, there are definitions for:

ERROR: parent/2

a)

The arity of predicate parent is only 1

b)

The arity of predicate parent should be 1

c)

The arity of predicate parent should be 2

d)

parent is not a predicate symbol

20.

Translate the English statement below into Prolog fact

I will pass this exam.

a)

will_pass(i, exam).

b)

will_pass(I, this_exam).

c)

Pass(i, exam).

d)

pass(i, Exam).

21.

Recommend a query from this unification

book(1,title1,author1).

a)

?- book(_,_,author1).

b)

?- book(_,X,author1).

c)

Both a and b are correct

d)

Neither a or b is correct

22.

Make use of Prolog interpreter, negate that the weather is sunny

a)

?- assert(sunny).

b)

?- retract(sunny).

c)

?- sunny.

d)

?- not_sunny.

23.

Relate the given English statement into Prolog rule

I will pass the examination if I have reviewed the lectures and lab activities.

a)

pass(I, Examination) :- reviewed(I, Lectures), reviewed(I, Lab_activities).

b)

pass(I, Examination) :- reviewed(_, Lectures), reviewed(_, Lab_activities).

c)

pass(I, Examination) :- reviewed(I, _), reviewed(I, _).

d)

None of the above

24.

Apply the English statement

Mitch likes ice cream.

into Prolog fact

a)

likes(mitch,ice_cream).

b)

likes(Mitch,ice_cream).

c)

likes(Mitch,Ice_cream).

d)

Likes(mitch,ice_cream).

25.

Translate the English meaning of

professor(X, Y) :- teaches(X, C), studies(Y, C).

a)

Y is a professor of X if X teaches C and Y studies C.

b)

X is a professor of Y if X teaches C and Y studies C.

c)

X is a professor of Y if X and Y teach and study C.

d)

None of the above

26.

After adding “sunny”, prove that it is sunny in Prolog interpreter

a)

?- sunny.

b)

?- retract(sunny).

c)

?- assert(sunny).

d)

?- sunny(true).

27.

Predict the cause of error in line number

5 ?- assert(likes(maria.ice_cream)).

ERROR: Syntax error: Operator expected

a)

period

b)

comma

c)

parenthesis

d)

predicate symbol

28.

Simplify ?- X is 11/5 in Prolog arithmetic

a)

X = 2.2

b)

.2

c)

2

d)

X = 2

29.

Identify the cause of error in line number

3 ?- assert(parent(hank denise)).

ERROR: Syntax error: Operator expected

a)

period

b)

comma

c)

parenthesis

d)

predicate symbol

30.

Given a database named vegie.pl, determine the number of clauses

vegetarian(jose).

vegetarian(james).

vegetable(carrot).

vegetable(egg_plant).

likes(jose, X) :- vegetable(X).

loves(Who, egg_plant) :- vegetarian(Who).

a)

4

b)

3

c)

2

d)

6

31.

Originate the arity in

write(‘Prolog’),nl.

a)

1

b)

0

c)

nl

d)

write

32.

Predict the subgoal in

cone(Top, Middle, Bottom) :- scoop(Top), scoop(Middle), scoop(Bottom).

a)

scoop(Top), scoop(Middle), scoop(Bottom).

b)

cone(Top, Middle, Bottom).

c)

Top, Middle, Bottom

d)

scoop

33.

Conjunction means ____ , in Prolog it is written as ____

a)

And , Comma(,)

b)

Or , Comma(,)

c)

And , Semicolon(;)

d)

Or , Semicolon(;)

34.

In Plankalkül syntax, V represents

a)

subscript

b)

data type

c)

variable

35.

Fortran 0 was developed but was never implemented

a)

True

b)

False

36.

LISP is a functional programming language

a)

True

b)

False

37.

In LISp, Nil means

a)

next

b)

pointer

c)

node

d)

null

38.

The design of this language is based on the concept of orthogonality

a)

ALGOL 68

b)

ALGOL 60

c)

Fortran II

d)

Fortran IV

39.

First full implementation of an object-oriented language

a)

Java

b)

C#

c)

Smalltalk

d)

C++

40.

In ______, servlet’s output is displayed by the browser

a)

XSLT

b)

JSP

c)

PHP

d)

Python

41.

The popularity of this language suffered because the DoD no longer requires its use but also because of popularity of C++

a)

C

b)

C#

c)

Java

d)

Ada 95

e)

Smalltalk

42.

In this notation, the operator is written ahead of operands.

a)

Postfix

b)

Prefix

c)

Mixfix

d)

Infix

43.

Convert the expression below to prefix form

( (A * B) + (C / D) )

a)

(+ (* A B) / C D )

b)

(+ (* A B) (/ C D) )

c)

+ (* A B) (/ C D)

44.

Convert the expression below to infix form

a b + c d + *

a)

(a + b) * c + d

b)

a + b * c + d

c)

(a + b) * (c + d)

45.

Stack data structure is applied in _____ notation

a)

Prefix

b)

Mixfix

c)

Postfix

d)

Prefix

46.

Determine the postfix form of the given expression


( ( AX + ( B * CY ) ) / ( D ­ E ) )

a)

AX B CY * + / D E ­

b)

AX B CY * + D E ­ /

c)

/ + AX * B CY ­ D E

d)

AX B CY * D + E ­ /

47.

Convert

AX B C * +

to prefix form

a)

+ * AX B C

b)

AX + * B C

c)

A + X * B C

d)

+ AX * B C

48.

Recall the course policies and standards. Submission of copied laboratory exercise, case studies and laboratory exams will be graded as __.

a)

zero

b)

50%

c)

70%

d)

74%

49.

State the missing part in the university mission statement

To develop__________________ and empowered community members by providing relevant innovative and transformative knowledge, research, extension and production programs and services through progressive enhancement of its human resource capabilities and institutional mechanisms

a)

competitive graduates

b)

qualified graduates

c)

intelligent graduates

d)

competitive and qualified graduates

50.

Define the missing parts in the university vision statement

A leading university in the Philippines recognized for its proactive contribution to sustainable development through __ programs and services by 2030

a)

equitable and inclusive

b)

inclusive

c)

equitable

d)

inclusive and equitable