LISP Multiple Choice Questions on “Printing”.
1. Which can read expressions from data-files one at a time?
a) Print
b) With-open-file
c) Directive
D) None of the mentioned
Answer: b
Clarification: With-open-file can read expressions from data files one at a time, as they are needed for processing.
2. Which evaluates the single argument and prints it on a new line?
a) Format
b) With-open-file
c) Print
d) All of the mentioned
Answer: c
Clarification: The print primitive evaluates its single argument and prints it on a new line and prints a trailing space character.
3. Which primitive makes the messages consists of uppercase and lowercase letters?
a) Format
b) Directive
c) Print
d) Read
Answer: a
Clarification: Format primitive helps to create messages consisting of both uppercase and lowercase letters.
4. Which evaluates the expression twice during execution?
a) Read
b) Eval
c) Format
d) Print
Answer: b
Clarification: Eval evaluates the expression twice during execution.
5. Which makes it possible to print in tabulated columns?
a) Print
b) Read
c) Directive
d) Format
Answer: d
Clarification: Format also has the option to print the values in tabulated columns.
6. What is the output of the given statement?
span class="sy0"> * (setf temperature 100) * (print temperature)
a) 100
b) 200
c) 0
d) 100
100
Answer: d
Clarification: This statement will print the print forms and Print’s action.
Output:
100
100
7. What is the output of the given statement?
span class="sy0"> * (read)kirsh
a) Kirsh
b) T
c) Nil
d) Error
Answer: a
Clarification: This statement will print the given value.
Output:
KIRSH
8. What is the output of the given statement?
span class="sy0"> * (let ((p nil)); (print '(please type a patient name)) (setf p (read)); (print (append '(ok the name is) (list p)))p);
a) Nil
b) T
c) Error
d) The value you entered
Answer: d
Clarification: Thish statement will get the value from the terminal and print it.
Output:
dfa
(PLEASE TYPE A PATIENT NAME)
(OK THE NAME IS DFA)
DFA
9. What is the output of the given statement?
span class="sy0"> * (format t "Hello!")
a) Hello
b) T
c) Hello! NIL
d) None of the mentioned
Answer: c
Clarification: This statement will compare the value and print the result.
Output:
Hello! NIL
10. What is the output of the given statement?
span class="sy0"> * (setf name 'kirsh symptoms '(fever rash)) * (print (list 'patient name 'presented (length symptoms) 'symptoms symptoms))
a) Patient
b) Krish
c) 2
d) (PATIENT KIRSH PRESENTED 2 SYMPTOMS (FEVER RASH))
Answer: d
Clarification: This statement will count the number of symptoms in the given name and print the result.
Output:
(PATIENT KIRSH PRESENTED 2 SYMPTOMS (FEVER RASH))
