Computer Programming COS 201 (Chapter 1 & 2)
Computer Programming COS 201 (Chapter 1 & 2)
a) [1,2,3,4,5]
-record(student, {sname = "", sid})
b) [5,4,3,2,1]
S = #student{sname = "Samuel", sid = 5}
c) [1,5,4,2,3] S#student.sname
d) [3,2,5,4,1]
78. Which function converts a list to a tuple?
a) Samuel
a) tuple_to_list()
b) 5
b) list_to_tuple()
c) {Samuel, 5}
c) to_tuple()
d) Error
d) tuple_convert()
86. What is the keyword used to define records
79. Which function converts a tuple to a list?
in Erlang?
a) tuple_to_list()
a) tuple
b) list_to_tuple()
b) list
c) to_list()
c) record
d) convert_tuple()
d) define
80. How do you determine the size of a tuple in
87. Which method is used to update a record
Erlang?
value?
a) list_size(tuple)
a)Redefine the record completely
b) tuple_count(tuple)
b) Change the specific field and assign to a
c) tuple_size(tuple)
new variable
d) size(tuple)
c) Use the update_field method
81. What is the output of the following code
d) Use the change_record method
snippet?
88. Which of the following is not an operation on
tuple_to_list({1,2,3,4,5}) tuples?
a) tuple_to_list()
b) tuple_size()
a) [1,2,3,4,5]
c) tuple_concat()
b) {1,2,3,4,5}
d) is_tuple()
c) [5,4,3,2,1]
89. What is the size of the tuple {abc, 50, pqr, 60,
d) {5,4,3,2,1}
{xyz, 75}}?
82. What is the syntax for defining a record in
a) 5
Erlang?
b) 4
a) record_name(field1, field2, ...)
c) 6
b) record(recordname, {field1, field2, ...})
d) 2
c) {recordname, field1, field2}
90. What does the is_tuple() function check?
d) tuple(recordname, field1, field2)
a) If the value is a tuple
83. What does the following syntax achieve?
b) If the tuple is empty
c) If the tuple contains integers only
-record(student, {sname = "", sid})
d) If the tuple has a specific size
91. How do you define a tuple in Erlang?
a) Defines a tuple named "student"
a) {element1, element2, ...}
b) Defines a record with fields sname and
b) [element1, element2, ...]
sid
c) (element1, element2, ...)
c) Defines a list with default values
d) tuple(element1, element2, ...)
d) Defines a record with fixed values
Made with love by THRIVE LINK
92. What does the following Erlang record b) Variables, function applications, and
declaration represent? function creations
c) Constants, operations, and data types
-record(student, {sname = "", sid}) d) Variables, records, and modules
a) file:read_file()
b) file:open()
c) file:write()
d) file:delete()
122. What does the file:delete() function in
Erlang do?
a) Deletes the contents of a file
b) Deletes the specified file
c) Renames the specified file
d) Updates the contents of a file
123. What is the purpose of the
filelib:file_size() function in Erlang?
a) Determine the size of a file in bytes
b) Read the contents of a file
c) Write data to a file
d) Delete a file
124. Which method in Python reads the
entire content of a file?
a) readlines()
b) read()
c) readline()
d) None of the above
105. What is the default mode when opening
a file in Python?
a) Read mode
b) Write mode
c) Append mode
d) Execute mode
106. What does the a mode do when
opening a file in Python?
a) Overwrites the file
b) Appends data to the file
c) Reads the file contents
d) Deletes the file