Midterm, Chapter 1-6

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4): A. 0, 1, 2, 3 B. 1, 2, 3 C. 1, 2, 3, 4 D. 0, 1, 2, 3, 4

0, 1, 2, 3

What is the decimal value of the following binary number? 10011101 A. 8 B. 157 C. 28 D. 156

157 Step 1 1x2^7 + 0x2^6 + 0x2^5 + 1x2^4 + 1x2^3 + 1x2^2 + 0x2^1 + 1x2^0 Step 2 1x128 + 0x64 + 0x32 + 1x16 + 1x8 + 1x4 + 0x2 + 1x1 = 128 + 0 + 0 + 16 + 8 + 4 + 0 + 1 Step 3 128 + 0 + 0 + 16 + 8 + 4 + 0 + 1 = 157

What is the output of the following command, given that value1 = 2.0 and value2 = 12? print(value1 * value2) A. 24.0 B. value1 * value2 C. 2.0 * 12 D. 24

24.0

What will be displayed after the following code is executed? for num in range(0, 20, 5): num += num print(num) A. 5 10 15 B. 25 C. 0 5 10 15 20 D. 30

30

Which of the following is considered to be the world's first programmable electronic computer? A. ENIAC B. Gateway C. Dell D. IBM

ENIAC

A computer is a single device that performs different types of tasks for its users. A. True B. False

False

A function definition specifies what a function does and causes the function to execute. A. True B. False

False

A local variable can be accessed from anywhere in the program. A. True B. False

False

In a nested loop, the inner loop goes through all of its iterations for each iteration of the outer loop. A. True B. False

False

Short -circuit evaluation is only performed with the not operator.

False

The Python language is not sensitive to block structuring of code. A. True B. False

False

Unlike other languages, in Python the number of values a function can return is limited to one. A. True B. False

False

A bit that is turned off is represented by the value -1. A. True B. False

False Value is 0

The acronym ________ refers to the fact that the computer cannot tell the difference between good data and bad data.

GIGO Garbage in, Garbage out

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.

The path is D:\sample\test.

A flowchart is a tool used by programmers to design programs. A. True B. False

True

An action in a single alternative decision structure is performed only when the condition is true. A. True B. False

True

In a flowchart, both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested. A. True B. False

True

In a nested loop, the inner loop goes through all of its iterations for each iteration of the outer loop. A. True B. False

True

The CPU understands instructions written in a binary machine language. A. True B. False

True

The if statement causes one or more statements to execute only when a Boolean expression is true. A. True B. False

True

To assign a value to a global variable in a function, the global variable must be first declared in the function. A. True B. False

True

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 B. False

True

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?x < y or z > x A. 5 B. False C. True D. 8

True Why: ... If (x=5) < (y=3), this is False. OR = the operator , one of these expressions must be true. (z=8) > (x=5), this is True The whole statement is True because it uses the OR operator not the AND condition.

A Boolean variable can reference one of two values which are A. True or False B. Y or N C. yes or no D. T or F

True or False

Python uses ________ to categorize values in memory.

data types

In flowcharting, the ________ symbol is used to represent a Boolean expression.

diamond

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

end

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) ________ data type. sold = 256.752 A. float B. currency C. int D. str

float

In Python, you would use the ________ statement to write a count-controlled loop.

for

The code for a function is known as a function ________.

function definition

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive? A. if 10 > y and y < 50: B. if y >= 10 or y <= 50: C. if 10 < y or y > 50: D. if y >= 10 and y <= 50:

if y >= 10 and y <= 50:

Which of the following statements causes the interpreter to load the contents of the random module into memory? A. upload random B. download random C. import random D. load random

import random

Where does a computer store a program and the data that the program is working with while the program is running? A. in the CPU B. in main memory C. in the microprocessor D. in secondary storage

in main memory

A ________ variable is created inside a function. A. constant B. local C. global D. named constant

local

A disk drive stores data by ________ encoding it onto a circular disk.

magnetically

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

operands

When using the ________ logical operator, one or both of the subexpressions must be true for the compound expression to be true. A. maybe B. and C. or D. not

or

Arguments are passed by ________ to the corresponding parameter variables in a function.

position

The first operation is called the ________ and its purpose is to get the first input value that will be tested by the validation loop. A. loop validation B. first input C. loop set read D. priming read

priming read

A ________ has no moving parts and operates faster than a traditional disk drive. A. hyper drive B. solid state drive C. jumper drive D. DVD drive

solid state drive

Python comes with ________ functions that have already been prewritten for the programmer. A. key B. library C. standard D. custom

standard

The ________ design technique can be used to break down an algorithm into functions. A. subtask B. top-down C. block D. simplification

top-down

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 allows the end-user to always see the value of the sales tax. B. 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. C. 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. D. If the tax amount changes to 7.0%, the value will only have to be changed in one place.

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. 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. If the tax amount changes to 7.0%, the value will only have to be changed in one place.

The disk drive is a secondary storage device that stores data by ________ encoding it onto a spinning circular disk. A. magnetically B. digitally C. optically D. electrically

Magnetically

________ is a type of memory that can hold data for long periods of time, even when there is no power to the computer.

Secondary storage

A(n) ________ expression is made up of two or more Boolean expressions.

compound

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

concatenation

What type of loop structure repeats the code based on the value of Boolean expression? A. condition-controlled loop B. Boolean-controlled loop C. number-controlled loop D. count-controlled loop

condition-controlled loop

What will be displayed after the following code is executed? count = 4 while count < 12: print("counting") count = count + 2 A. counting counting B. counting counting counting counting C. counting counting counting D. counting counting counting counting

counting counting counting counting


Ensembles d'études connexes

Chapter 6: The Nonverbal Dimension of Communication

View Set

Chemistry-Unit 3: Investigating Patterns in the Periodic Table

View Set

ECON MID TERM HW QUESTIONS 4(part 1)

View Set

Chapter 17 - Fundamentals of Discounted Cash Flow Analysis

View Set

Ch 58: Professional Roles and Leadership

View Set