# LISP Questions & Answers – S-Expression – 2

This set of LISP Questions and Answers for Freshers focuses on “S-Expression – 2”.

1. If S1, S2, S3… are S-expressions then list: (S1 S2 S3 ….) is a/an ____
a) Atom
b) Error will occur
c) S-expression
d) Primitive

Explanation: According to recursive definition of S-expression if S1, S2, S3… are S-expressions then list: (S1 S2 S3 ….) is also an S-expression. S-expression is short form of symbolic expressions.

2. What are examples of some of the atoms?
a) Numeric, Integer, Ratio
b) Numeric, Lists
c) Lists
d) Cons of two atoms

Explanation: Atoms consist of Literals, Numbers, Integers, Ratios, Flonum. Lists are formed from atoms. Cons of two atoms is referred to as List.

3. Which of the following can be considered as List?
a) Number
b) T
c) NIL
d) Empty

Explanation: An empty thing is also considered as List. Empty thing means the braces () with no arguments. Numbers are not counted in Lists.

4. Is LISP a case sensitive language.
a) Yes
b) No

Explanation: LISP is not a case sensitive language. Example: (print ‘a) will behave same as (PRINT ‘A).

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

Note: Join free Sanfoundry classes at Telegram or Youtube
`(write 'ATOMS)`

a) ATOMS
b) error
c) A
d) Toms

Explanation: In LISP primitive programming language, write is a keyword that is used to print things on the output terminal of the compiler.
Output: ATOMS

6. What is the use of (WRITE ‘Argument)?
a) It converts argument in small letters to capital letters
b) It returns capital letters from the string
c) Same as (write ‘argument)
d) It converts the string into alphabetical order/sequence

Explanation: It works same as (write ‘argument) because LISP is case insensitive language.

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

`(write '(a b c d))`

a) A B C D
b) A
c) Error
d) B C D

Explanation: With use of write primitive, we can write space separated words with the use of braces.
Output: A B C D

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

`(write 1)`

a) 1
b) ‘ is not used so error occurs
c) Error
d) No output

Explanation: It will print number 1. If we use ‘1 then that will not be a number. ‘1 will convert number 1 to a list and it will have properties of list and not numbers.
Output: 1

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

`(write '+/_)`

a) Ascii value of + divides by that of _
b) Error
c) +/_
d) + only

Explanation: It will not print division of ASCII values of + and _. Write will print arguments as it is in the output.
Output: +/_

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

`(write '#)`

a) Error
b) #
c) ASCII value of #
d) # will be printed without using ‘

Explanation: Compiler error will occur after the execution of this statement.
Output: Compiler error: “objects printed as # in view of *PRINT-LEVEL* cannot be read back in”.

Sanfoundry Global Education & Learning Series – LISP Programming Language. 