Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Exploring Prolog and AI Concepts

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the primary data structure used in Prolog?

a)

Graphs

b)

Terms

c)

Arrays

d)

Lists

2.

Define a fact in Prolog.

a)

A fact in Prolog is a function that returns a value.

b)

A fact in Prolog is a variable that can change over time.

c)

A fact in Prolog is a statement that asserts something is true, e.g., 'predicate(arguments).'.

d)

A fact in Prolog is a comment that explains code.

3.

What is a rule in Prolog?

a)

A rule in Prolog is a data structure that stores facts.

b)

A rule in Prolog is a logical statement that defines relationships between facts, consisting of a head and a body.

c)

A rule in Prolog is a type of variable used in queries.

d)

A rule in Prolog is a command that executes a program.

4.

Explain the concept of backtracking in Prolog.

a)

Backtracking is a method for optimizing database queries in Prolog.

b)

Backtracking is a technique used to compile Prolog code into machine language.

c)

Backtracking is a way to improve the performance of Prolog by using parallel processing.

d)

Backtracking is a search strategy in Prolog that explores options and reverts to previous states when a dead end is reached.

5.

How does Prolog handle variables?

a)

Prolog variables can only hold numeric values.

b)

Prolog uses variables as placeholders that can unify with terms during execution.

c)

Prolog treats variables as constants throughout execution.

d)

Prolog variables cannot be unified with any terms.

6.

What is the purpose of the cut operator in Prolog?

a)

The cut operator in Prolog is used to control backtracking and commit to choices made.

b)

The cut operator is used to print output to the console.

c)

The cut operator is a method for optimizing memory usage.

d)

The cut operator is used to define new predicates.

7.

Describe how knowledge is represented in Prolog.

a)

Prolog uses only numerical data to represent knowledge.

b)

Knowledge in Prolog is represented solely through natural language descriptions.

c)

Knowledge in Prolog is represented through facts, rules, and queries.

d)

Knowledge in Prolog is represented through images and videos.

8.

What is the difference between a predicate and a function in Prolog?

a)

A predicate represents a relationship and can be true or false; a function computes a value.

b)

A predicate is a function that always returns true; a function can only return false.

c)

A predicate is used for arithmetic operations; a function is used for logical comparisons.

d)

A predicate is a type of variable; a function is a constant value.

9.

How do you define a list in Prolog?

a)

A list in Prolog is defined using curly braces, e.g., {element1, element2, element3}.

b)

A list in Prolog is defined using parentheses, e.g., (element1, element2, element3).

c)

A list in Prolog is defined using square brackets, e.g., [element1, element2, element3].

d)

A list in Prolog is defined using angle brackets, e.g., .

10.

What is unification in Prolog?

a)

Unification refers to the way Prolog handles memory management during execution.

b)

Unification is the process of combining two Prolog programs into one.

c)

Unification is a method for optimizing Prolog queries for faster execution.

d)

Unification is the process of making two Prolog terms identical by finding substitutions for their variables.

11.

Explain the term 'logic programming'.

a)

Logic programming focuses solely on user interface design.

b)

Logic programming is a method for creating mobile applications.

c)

Logic programming is a programming paradigm that uses formal logic to express programs as a set of relations and rules.

d)

Logic programming is a type of hardware programming.

12.

How does Prolog differ from imperative programming languages?

a)

Prolog uses explicit commands to control program flow.

b)

Prolog requires manual memory management like imperative languages.

c)

Prolog differs from imperative programming languages in that it is based on logic and rules rather than explicit commands and state changes.

d)

Prolog is primarily focused on object-oriented programming principles.

13.

What role does Prolog play in artificial intelligence?

a)

Prolog is primarily used for numerical computations in AI.

b)

Prolog is a graphical programming language for AI applications.

c)

Prolog plays a significant role in artificial intelligence by enabling symbolic reasoning and knowledge representation.

d)

Prolog is mainly focused on machine learning algorithms in AI.

14.

What is a Prolog interpreter?

a)

A Prolog interpreter is a programming language.

b)

A Prolog interpreter is a program that executes Prolog code.

c)

A Prolog interpreter is a type of database.

d)

A Prolog interpreter is a tool for compiling C code.

15.

How can Prolog be used for natural language processing?

a)

Prolog can represent and process natural language through symbolic reasoning and parsing.

b)

Prolog is primarily used for numerical computations.

c)

Prolog can only handle structured data, not language.

d)

Prolog is a graphical programming language for visual applications.

16.

What is the significance of the ':-' symbol in Prolog?

a)

The ':-' symbol signifies a rule or goal, indicating that the head is true if the body is true.

b)

The ':-' symbol indicates a variable declaration.

c)

The ':-' symbol is used for comments in Prolog.

d)

The ':-' symbol represents a function call in Prolog.

17.

How do you perform recursion in Prolog?

a)

Use only iterative loops to solve problems.

b)

Define a base case and a recursive case in a predicate.

c)

Define multiple base cases without recursion.

d)

Create a single predicate without any conditions.

18.

What are the advantages of using Prolog for AI applications?

a)

Prolog's reliance on imperative programming

b)

Prolog's declarative nature, backtracking, rule-based support, natural language processing capabilities, and efficient recursion handling.

c)

Inability to handle logical reasoning effectively

d)

Limited support for complex data structures

19.

Explain the concept of a knowledge base in Prolog.

a)

A knowledge base in Prolog is solely for storing text documents.

b)

A knowledge base in Prolog only contains numerical data.

c)

A knowledge base in Prolog consists of facts and rules that represent information and enable logical reasoning.

d)

A knowledge base in Prolog is a collection of user preferences.

20.

What is the purpose of the 'assert' and 'retract' predicates in Prolog?

a)

The 'assert' predicate is used for debugging, while 'retract' is for optimization.

b)

The 'assert' predicate removes facts/rules, and the 'retract' predicate adds them.

c)

Both 'assert' and 'retract' are used to query existing facts.

d)

The 'assert' predicate adds facts/rules, and the 'retract' predicate removes them.