Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Gaddis Python 2e Chapter 02


 

Download  file with the answers

If you are not a member register here to download this file 


 

Chapter Two

MULTIPLE CHOICE

1. What type of error produces incorrect results but does not prevent the program from running?
a. syntax
b. logic
c. grammatical
d. human

2. The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.
a. five
b. four
c. three
d. six

3. What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?
a. Flowchart
b. Algorithm
c. Code
d. Pseudocode

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

5. 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. string_input

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

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

8. 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

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

10. 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.54

11. The output of the following print statement is:
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’
12. If value1 is 2.0 and value2 is 12, what is the output of the following command?
print(value1 * value2)
a. 24
b. value1 * value2
c. 24.0
d. 2.0 * 12

13. 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()

14. 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.

15. What symbol is used to mark the beginning and end of a string?
a. Slash
b. Asterisk
c. Quotation
d. Comma

TRUE/FALSE

1. True/False: Comments in Python begin with the # character.

ANS: T

2. True/False: When using the camelCase naming convention, the first word of the variable name is written in lowercase letters and the first character of the second and subsequent words are written in uppercase letters.

ANS: T

3. True/False: According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.
ANS: F

4. True/False: Python allows programmers to break a statement into multiple lines.

ANS: T

5. True/False: Python formats all floating-point numbers to two decimal places when outputting using the print statement.

ANS: F

6. True/False: A flowchart is a tool that programmers use to design programs.

ANS: T

7. True/False: In Python, math expressions are evaluated from left to right, no matter what the operators are.

ANS: F

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

ANS: T

9. True/False: In Python, print statements written on separate lines do not necessarily output on separate lines.

ANS: T

10. True/False: The \t escape character causes the output to skip over to the next horizontal tab.

ANS: T

FILL IN THE BLANK

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

ANS: Comments

2. The % symbol is the remainder operator and it is also known as the _______________ operator.

ANS: modulus

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

ANS: escape

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

ANS: formatting

5. The result of the expression 12.3 + 6.7 is _______________.

ANS: 19.0

6. When applying the .3f formatting specifier to the following number, 76.15854, the result is _______________.

ANS: 76.159

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

ANS: software requirement

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

ANS: variable

9. Python uses _______________ to categorize values in memory.

ANS: data types

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

ANS: concatenation

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!