Logic Programming in Prolog - Lecture 10: Arithmetic
15 Questions
4 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following arithmetic functions is available in Prolog?

  • Square root (correct)
  • Sorting
  • String concatenation
  • File input/output
  • In Prolog, what must be true for variables appearing in an arithmetic expression?

  • They must be constants
  • They must already be bound with values (correct)
  • They must be unbound
  • They must be declared as strings
  • What is the result of the arithmetic expression in Prolog: $Y = 10, Z = Y + 1$?

  • Y=11, Z=11
  • Y=10, Z=10
  • Y=11, Z=10
  • Y=10, Z=11 (correct)
  • Which of the following is an arithmetic operator in Prolog?

    <p>/ (division)</p> Signup and view all the answers

    What does Prolog use to specify the order of operations in arithmetic expressions?

    <p>Parentheses</p> Signup and view all the answers

    Which of the following is a relational operator in Prolog?

    <p>== (equality)</p> Signup and view all the answers

    What is the value of X when X = 10 mod 4?

    <p>2</p> Signup and view all the answers

    What is the solution when X = 30, Y = 5, and Z = X + Y + X*Y?

    <p>185</p> Signup and view all the answers

    What is the result of the arithmetic expression 6+4?

    <p>10</p> Signup and view all the answers

    What is the outcome of the append operation append([1,2,3,4],[5,6,7,8,9],L)?

    <p>[1,2,3,4,5,6,7,8,9]</p> Signup and view all the answers

    What is the value of sqrt(36)?

    <p>6.0</p> Signup and view all the answers

    What does the predicate 'prefix(P,L):append(P,_,L)' define?

    <p>Finding prefixes of a list</p> Signup and view all the answers

    What are the values of L1 and L2 in the operation append(L1,L2,[1,2,3])?

    <p>[], [1,2,3]</p> Signup and view all the answers

    What is the value of X when X = 1 + 2?

    <p>3</p> Signup and view all the answers

    What does the statement 'If the first two arguments L1,L2 are lists and the third argument is an variable, the third argument is bound to a list comprising the first two lists concatenated' describe?

    <p>Appending two lists</p> Signup and view all the answers

    More Like This

    Use Quizgecko on...
    Browser
    Browser