Week 2 Flashcards

1
Q

Comments in Python begin with the # character

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

When using the camelCase naming convention, the first word of the variable name is written in lowercase and the first characters of all subsequent words are written in uppercase.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Python allows programmers to break a statement into multiple lines.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Python formats all floating-point numbers to two decimal places when outputting with the print statement.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A flowchart is a tool used by programmers to design programs

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In Python, math expressions are always evaluated from left to right, no matter what the operators are.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produced.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In Python, print statements written on separate lines do not necessarily output on separate lines.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The \t escape character causes the output to skip over to the next horizontal tab.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Since a named constant is just a variable, it can change any time during a program’s execution.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the informal language, used by programmers use to create models of programs, that has no syntax rules and is not meant to be compiled or executed?
a. flowchart
b. algorithm
c. source code
d. pseudocode

A

D. pseudocode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A(n) __________ is a diagram that graphically depicts the steps that take place in a program?
a. flowchart
b. algorithm
c. source code
d. pseudocode

A

A. Flowchart

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The __________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.
a. input()
b. output()
c. eval_input()
d. str_input()

A

a. input()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The line continuation character is a
a. #
b. %
c. &
d. \

A

d. \

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which mathematical operator is used to raise 5 to the second power in Python?
a. /
b. **
c. ^
d. ~

A

b. **

16
Q

In a print statement, you can set the __________ argument to a space or empty string to stop the output from advancing to a new line.
a. stop
b. end
c. separator
d. newLine

A

b. end

17
Q

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) __________ data type.
sold = 256.752
a. int
b. float
c. str
d. currency

A

b. float

18
Q

After the execution of the following statement, the variable price will reference the value __________.
price = int(68.549)
a. 68
b. 69
c. 68.55
d. 68.6

A

a. 68

19
Q

What is the output of the following print statement?
print ‘I'm ready to begin’
a. Im ready to begin
b. I'm ready to begin
c. I’m ready to begin
d. ‘I'm ready to begin’

A

c. I’m ready to begin

20
Q

What is the output of the following command, given that value1 = 2.0 and value2 = 12?
print(value1 * value2)
a. 24
b. value1 * value2
c. 24.0
d. 2.0 * 12

A

c. 24.0

21
Q

What is the output of the following print statement?
print(‘The path is D:\sample\test.’)
a. ‘The path is D:\sample\test.’
b. The path is D:\sample\test.
c. The path is D\sample\test.
d. The path is D:\sample\test.

A

d. The path is D:\sample\test.

22
Q

The __________ built-in function is used to read a number that has been typed on the keyboard.
a. input()
b. read()
c. get()
d. keyboard()

A

a. input()

23
Q

Which of the following will display 20%?
a. print(format(20, ‘.0%’)) <enter>
b. print(format(0.2, '.0%')) <enter>
c. print(format(0.2 * 100, '.0%')) <enter>
d. print(format(0.2, '%')) <enter></enter></enter></enter></enter>

A

b. print(format(0.2, ‘.0%’)) <enter></enter>

24
Q

What symbol is used to mark the beginning and end of a string?
a. a slash (/)
b. an asterisk (*)
c. a quote mark (“)
d. a comma (,)

A

c. a quote mark (“)

25
Q

To use Python’s turtle graphics, you must include which of the following statements in your program?
a. import turtle_module
b. import turtle_graphics
c. import turtle
d. import Turtle

A

c. import turtle

26
Q

The Python turtle is initially positioned in the __________ of a graphics window and it first appears, by default, to be heading __________.
a. center, up
b. top left corner, east
c. bottom left corner, down
d. center, east

A

d. center, east

27
Q

Select all that apply. Which of the following are steps in the program development cycle?
a. design the program
b. write the code and correct syntax errors
c. test the program
d. correct logic errors

A

a. design the program
b. write the code and correct syntax errors
c. test the program
d. correct logic errors

28
Q

Select all that apply. Assume you are writing a program that calculates a user’s total order cost that includes sales tax of 6.5%. Which of the following are advantages of using a named constant to represent the sales tax instead of simply entering 0.065 each time the tax is required in the code?
a. It will be easier for another programmer who may need to use this code to understand the purpose of the number wherever it is used in the code.
b. If the tax amount changes to 7.0%, the value will only have to be changed in one place.
c. It allows the end-user to always see the value of the sales tax.
d. It avoids the risk that any change to the value of sales tax will be made incorrectly or that an instance of the tax value might be missed as might occur if the number had to be changed in multiple locations.

A

a. It will be easier for another programmer who may need to use this code to understand the purpose of the number wherever it is used in the code.

29
Q

_______ are notes of explanation that document lines or sections of a program.

A

comments

30
Q

The % symbol is the remainder operator, also known as the ___________ operator.

A

modulus

31
Q

A(n) __________ character is a special character that is preceded with a backslash (), appearing inside a string literal.

A

escape

32
Q

The __________ specifier is a special set of characters that specify how a value should be formatted.

A

formatting

33
Q

When applying the .3f formatting specifier to the number 76.15854, the result is __________.

A

76.159

34
Q

A(n) __________ is a single task that the program must perform in order to satisfy the customer.

A

software requirement

35
Q

In the expression 12.45 + 3.6, the values to the right and left of the + symbol are the __________.

A

operands

36
Q

A(n) __________ is a name that represents a value stored in the computer’s memory.

A

variable

37
Q

Python uses __________ to categorize values in memory.

A

data types

38
Q

When the + operator is used with two strings, it performs string __________.

A

concatenation