Readable Code — Unit test Answers

5 verified answers1 views
1
Free Preview

Which syntax error in programming is unlikely to be highlighted by a compiler or an interpreter?

A
a variable name misspelling
B
a missing space
C
a comma in place of a period
D
a missing closing quotation mark
2
Free Preview

In Python, arrays are usually reserved for

A
sorting operations.
B
indexing operations.
C
searching operations.
D
numerical operations.
3

What happens when a Boolean expression is evaluated?

A
If the condition evaluates as True, then the next statement is executed.
B
If the condition evaluates as True, then nothing happens.
C
If the condition evaluates as False, then the next statement is false.
D
If the condition evaluates as False, then the next statement is executed.
4

Which set of variables will make code easier to understand?

A
a, b, c
B
sum, price, count
C
xii, xix, xxi
D
x, y, z
5

Which best describes the condition under which the Unicode output is the same as plain text?

A
when the text contains no punctuation
B
when the text contains only characters that are part of Unicode
C
when the text contains only characters that are part of ASCII
D
when the text contains no numbers
6

A program is run line by line to determine the source of a logic error. Which best describes the specific tool being used?

A
compiler
B
interpreter
C
stepping function
D
beta tester
8

Which statement about well-formatted code is true?

A
Well-formatted code is consistently aligned to the right margin to make it more readable.
B
Well-formatted code has no blank lines that could confuse the person reading it.
C
Well-formatted code is broken into meaningful segments to make it easier to understand.
D
Well-formatted code uses highlighting to feature important statements.
9

Effective character encoding requires

A
standardized code.
B
compatible browsers.
C
common languages.
D
identical operating systems.
10

Which can be used to decode a Unicode character encoding into text?

A
stringVariable=unicodeString.decode(decoding= “utf-8”, errors= “strict”)
B
stringVariable=unicodeString.encode(encoding= “utf-8”, errors= “strict”)
C
stringVariable=unicodeString.decode(encoding= “utf-8”, errors= “strict”)
D
stringVariable=unicodeString.encode(decoding= “utf-8”, errors= “strict”)
11

Comments should

A
give the reader the background of the programmer.
B
be written for every line of code.
C
communicate the purpose of the code that follows it.
D
give information about how many hours it took to write the code.
12

Which printout will result from the snippet of code?supplies = ["pencil", "notebook", "backpack", "pen", "calculator"]print("These are the supplies in the list:\n", supplies)

A
[‘pencil’, ‘notebook’, ‘backpack’, ‘pen’, ‘calculator’]
B
These are the supplies in the list: [‘pencil’, ‘notebook’, ‘backpack’, ‘pen’, ‘calculator’]
C
These are the supplies in the list: [‘pencil’, ‘notebook’, ‘backpack’, ‘pen’, ‘calculator’]
D
These are the supplies in the list:\n [‘pencil’, ‘notebook’, ‘backpack’, ‘pen’, ‘calculator’]
14

The introduction of the 8-bit computer expanded the number of bytes available for encoding. This led to the development of

A
octets.
B
Apple and Xerox.
C
ASCII.
D
Unicode.
15

Which are steps taken to diagnose a computer problem?

A
reproducing the problem and using error codes
B
reproducing the problem and troubleshooting
C
using error codes and troubleshooting
D
using error codes and stepping functions
16

Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?

A
errors= “strict”
B
errors= “fix”
C
errors= “ignore”
D
errors= “replace”
17

What allows a programmer to write code quickly and efficiently for an action that must be repeated?

A
an iteration
B
an index
C
an argument
D
a queue
18

A stepping function allows a program

A
to determine its own variables.
B
to be inspected line by line.
C
to translate code between programming languages.
D
to identify problems in code by searching for correct syntax.
19

While running a program, Sasha enters a negative number when a positive value was expected. Which type of error is likely to occur?

A
syntax
B
run-time
C
logic
D
interpreter
20

Indenting the start and finish of segments

A
requires the new programmers to insert comments of their own.
B
requires a lot of extra effort for the programmer.
C
makes the flow of the program more difficult to follow.
D
makes the flow of the program easier to follow.

Did you find these answers helpful?