Prolog is a declarative, logic-based programming language that was developed in the early 1970s by Alain Colmerauer and Philippe Roussel at the University of Aix-Marseille, France. The name “Prolog” stands for “Programming in Logic.”
Key features and characteristics of Prolog include:
Logic Programming Paradigm: Prolog is based on the principles of logic programming, which revolves around defining relationships and rules between facts and entities rather than specifying a sequence of steps to achieve a goal.
Facts and Rules: In Prolog, knowledge is represented using facts and rules. Facts represent simple statements or relationships between entities, while rules define logical implications or conditions that need to be satisfied.
Predicates: Predicates are the building blocks of Prolog programs. They are used to define relationships between objects and properties. Each predicate has a unique name and may take one or more arguments.
Pro Tip
Want to assess your learners online? Create an online quiz for free!
Unification: Unification is a fundamental concept in Prolog that allows the system to match queries with facts and rules. It involves finding substitutions for variables that make two terms identical.
Backtracking: Prolog uses a powerful backtracking mechanism to find multiple solutions to a problem. If a certain rule or fact fails to satisfy a query, Prolog will backtrack and attempt alternative possibilities.
In this article
- Part 1: 30 Prolog quiz questions & answers
- Part 2: Download Prolog questions & answers for free
- Part 3: Free online quiz creator – OnlineExamMaker
Part 1: 30 Prolog quiz questions & answers
1. Prolog is a programming language based on which paradigm?
a) Imperative programming
b) Object-oriented programming
c) Functional programming
d) Logic programming
Answer: d) Logic programming
2. In Prolog, knowledge is represented using:
a) Variables
b) Loops
c) Facts and rules
d) Functions
Answer: c) Facts and rules
3. What is the fundamental concept in Prolog that allows the system to match queries with facts and rules?
a) Unification
b) Backtracking
c) Recursion
d) Inheritance
Answer: a) Unification
4. Predicates in Prolog are used to define:
a) Relationships between objects and properties
b) Loops
c) Mathematical operations
d) Conditional statements
Answer: a) Relationships between objects and properties
5. Prolog uses _______ to find multiple solutions to a problem.
a) Overloading
b) Recursion
c) Backtracking
d) Polymorphism
Answer: c) Backtracking
6. Which of the following represents a Prolog rule in the form of “Head :- Body”?
a) “Goal -> Condition”
b) “If Condition Then Goal”
c) “Conclusion | Conditions”
d) “Head :- Body”
Answer: d) “Head :- Body”
7. What does the “Head” of a Prolog rule represent?
a) The conclusion or goal
b) The sub-goals to be met
c) The conditions for backtracking
d) The name of the predicate
Answer: a) The conclusion or goal
8. In Prolog, what is the purpose of the “Body” in a rule?
a) To specify the arguments for the predicate
b) To define the name of the predicate
c) To contain the conditions or sub-goals to be met
d) To represent the result of the predicate
Answer: c) To contain the conditions or sub-goals to be met
9. Prolog supports which of the following programming paradigms in its core functionality?
a) Imperative programming
b) Object-oriented programming
c) Functional programming
d) Logic programming
Answer: d) Logic programming
10. Which term is used in Prolog to refer to finding alternative solutions by undoing previous decisions?
a) Redo
b) Retry
c) Backtrack
d) Restart
Answer: c) Backtrack
11. What is the operator used for unification in Prolog?
a) &&
b) ||
c) =
d) ==
Answer: c) =
12. Prolog rules without a body are known as:
a) Undefined rules
b) Empty rules
c) Facts
d) Clauses
Answer: c) Facts
13. In Prolog, which operator is used to represent logical OR?
a) &&
b) ,
c) !
d) ;
Answer: d) ;
14. In Prolog, which symbol is used to represent the end of a query?
a) !
b) .
c) :
d) $
Answer: b) .
15. What is the correct syntax for a Prolog rule representing “X is the mother of Y”?
a) mother(X, Y) :-
b) X(mother, Y) :-
c) Y is mother(X) :-
d) mother(X) = Y :-
Answer: a) mother(X, Y) :-
Part 2: Download Prolog questions & answers for free
Download questions & answers for free
16. In Prolog, which built-in predicate is used to check equality between terms?
a) equal
b) ==
c) compare
d) =
Answer: d) =
17. How does Prolog handle variables in queries?
a) It automatically assigns values to variables.
b) It replaces variables with constants.
c) It unifies variables with values that satisfy the query.
d) It ignores variables in queries.
Answer: c) It unifies variables with values that satisfy the query.
18. In Prolog, what is the purpose of the cut (!) operator?
a) To terminate the program immediately.
b) To prevent backtracking beyond its position.
c) To skip the current query and move to the next one.
d) To create a new rule.
Answer: b) To prevent backtracking beyond its position.
19. Which Prolog predicate is used to define arithmetic operations?
a) math
b) arith
c) is
d) compute
Answer: c) is
20. What does the term “Horn clause” refer to in Prolog?
a) A clause with multiple heads
b) A clause with a body but no head
c) A clause with a single head and an optional body
d) A clause with multiple bodies
Answer: c) A clause with a single head and an optional body
21. Prolog is commonly used for building which type of systems?
a) Procedural systems
b) Object-oriented systems
c) Rule-based expert systems
d) Functional systems
Answer: c) Rule-based expert systems
22. Which Prolog predicate is used to check if a list is empty?
a) empty
b) []
c) list_empty
d) empty_list
Answer: b) []
23. Which of the following represents a Prolog list with elements “1, 2, 3”?
a) [1, 2, 3]
b) (1, 2, 3)
c) {1, 2, 3}
d) <1, 2, 3>
Answer: a) [1, 2, 3]
24. Prolog allows for _______ recursion, where a rule calls itself with a reduced problem.
a) Direct
b) Indirect
c) Tail
d) Nested
Answer: c) Tail
25. Which built-in predicate is used to find the length of a list in Prolog?
a) list_length
b) len
c) length
d) list_len
Answer: c) length
Just so you know
With OnlineExamMaker quiz software, anyone can create & share professional online assessments easily.
26. Prolog supports which of the following types of variables?
a) Local variables
b) Global variables
c) Logical variables
d) Constant variables
Answer: c) Logical variables
27. In Prolog, what does the “fail” predicate do?
a) Terminates the program
b) Causes the current rule to fail and triggers backtracking
c) Returns the number of solutions found so far
d) Executes a built-in predicate
Answer: b) Causes the current rule to fail and triggers backtracking
28. Which Prolog predicate is used to check if an element exists in a list?
a) in
b) member
c) contains
d) element
Answer: b) member
29. Prolog is primarily based on which branch of mathematical logic?
a) Set theory
b) Predicate logic
c) Boolean algebra
d) Fuzzy logic
Answer: b) Predicate logic
30. Which Prolog built-in predicate is used to stop backtracking and commit to the current solution?
a) ;
b) !
c) ,
d) =>
Answer: b) !
Part 3: Best online quiz making platform – OnlineExamMaker
Save time and effort with automated grading, instantly generating scores and results for each respondent. OnlineExamMaker grades your quizzes automatically, and provides valuable insights for performance evaluation. Whether you are an educator looking to engage students or a business professional seeking effective training methods, OnlineExamMaker quiz maker is a reliable and efficient solution that streamlines the assessment process for improved learning outcomes.
Create Your Next Quiz/Exam with OnlineExamMaker