LISP Questions & Answers – S-Expression – 1

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “S-Expression – 1”.

1. What S-expression consists of?
a) Atoms and Lists
b) Numeric only
c) Literals only
d) Atoms only
View Answer

Answer: a
Explanation: S-expression consists of both Atoms and Lists. It also consists of numeric and literals.

2. All program statements and data in LISP are represented by S-expressions?
a) True
b) False
View Answer

Answer: a
Explanation: Yes, all the program statements and data are represented by S-expressions in LISP. S-expressions or symbolic expressions are the syntactic elements of the LISP programming language.

3. What are the basic building blocks of S-expressions?
a) Atoms
b) Lists
c) Numbers
d) Predicates
View Answer

Answer: a
Explanation: Atoms are building blocks of S-expressions. Even atoms are considered as a fundamental unit of LISP.
advertisement
advertisement

4. If X and Y are S-expression then (X.Y) is a/an ____
a) S-expression
b) Atom
c) List
d) Predicate
View Answer

Answer: a
Explanation: In LISP programming if X and Y are S-expressions then the dotted pair (X.Y) is also considered as S-expression.

5. Atoms are considered as S-expressions.
a) True
b) False
View Answer

Answer: a
Explanation: Atoms are also considered as S-expressions. Rather S-expressions are formed from atoms.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What will be the output of the following LISP statement?

(print 'first-statement)

a) FIRST-STATEMENT
b) FIRST
c) STATEMENT
d) –
View Answer

Answer: a
Explanation: Print will output the argument given to it as it is on the output terminal of the compiler.
Output: FIRST-STATEMENT
advertisement

7. What will be the output of the following LISP statement?

advertisement
(print 'Atom)

a) ATOM
b) A
c) TOM
d) ATOM infinitely
View Answer

Answer: a
Explanation: Print is used to write the argument provided to it on the output part of the program.
Output: ATOM

8. What will be the output of the following LISP statement?

(print 'List-atom)

a) LIST-ATOM
b) LIST
c) ATOM
d) –
View Answer

Answer: a
Explanation: Print primitive does not give an error if the argument has -(hyphen). It prints on output the argument provided to it.
Output: LIST-ATOM

9. What is the output of the following LISP statement?

(print 'list atom)

a) LIST ATOM
b) LIST
c) ATOM
d) Error
View Answer

Answer: d
Explanation: We cannot give space in print’s argument in this type of declaration. It will consider that two arguments are given to print primitive one being list and other is an atom. But we can give only one argument to print so it will give error.

10. What is the output of the following LISP statement?

(print '(list atom))

a) LIST ATOM
b) LIST
c) ATOM
d) Error
View Answer

Answer: a
Explanation: If we keep the space separated items in the braces then the print will not give error. The list and atom are two different words but they are bound in one single argument by use of braces.
Output: LIST ATOM.

Sanfoundry Global Education & Learning Series – LISP Programming Language.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.