Python Mid Term Study Guide

Ace your homework & exams now with Quizwiz!

A(n) ________ chart is also known as a structured chart. A) data B) hierarchy C) organizational D) flow

B) hierarchy

How many types of files are there? A) one B) two C) three D) more than three

B) two

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) The path is D:\sample\test.

A(n) ________ structure is a logical design that controls the order in which a set of statements execute. A) control B) sequence C) iteration D) function

A) control

The first line in a function definition is known as the function.... A) parameter B) return C) block D) header

D) header

Which of the following is associated with a specific file and provides a way for the program to work with that file? A) the file variable B) the file extension C) the filename D) the file object

D) the file object

________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation. A) Input validation B) Data validation C) Correcting input D) Correcting data

A) Input validation

The line continuation character is a.... A) \ B) # C) & D) %

A) \

A variable used to keep a running total is called a(n) A) accumulator B) summer C) running total D) total

A) accumulator

Multiple Boolean expressions can be combined by using a logical operator to create ________ expressions. A) compound B) logical C) mathematical D) sequential

A) compound

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

A) condition-controlled loop

A ________ variable is accessible to all the functions in a program file. A) global B) string C) local D) keyword

A) global

Which of the following is the correct if clause to determine whether choice is anything other than 10? A) if choice != 10: B) if choice != 10 C) if not(choice < 10 and choice > 10): D) if choice <> 10:

A) if choice != 10:

The Python library functions that are built into the Python ________ can be used by simply calling the required function. A) interpreter B) compiler C) code D) linker

A) interpreter

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

A) local

Which step creates a connection between a file and a program? A) open the file B) read the file C) close the file D) process the file

A) open the file

In a value-returning function, the value of the expression that follows the keyword ________ will be sent back to the part of the program that called the function. A) return B) sent C) def D) result

A) return

Which of the following is not a major component of a typical computer system? A) the operating system B) main memory C) secondary storage devices D) the CPU

A) the operating system

Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total? A) total += number B) total = number C) number += number D) total + number = total

A) total += number

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

B) 2, 4, 6, 8

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

B) False

What type of volatile memory is usually used only for temporary storage while running a program? A) TVM B) RAM C) TMM D) ROM

B) RAM

What does the following statement mean? num1, num2 = get_num() A) The function get_num() will receive the values stored in num1 and num2. B) The function get_num() is expected to return a value for num1 and for num2. C) The function get_num() is expected to return one value and assign it to num1 and num2. D) This statement will cause a syntax error.

B) The function get_num() is expected to return a value for num1 and for num2.

The smallest storage location in a computer's memory is known as a ____ A) byte B) switch C) bit D) ketter

C) bit

A set of statements that belong together as a group and contribute to the function definition is known as a... A) parameter B) return C) block D) header

C) block

The ________ built-in function is used to read a number that has been typed on the keyboard. A) read() B) get() C) keyboard() D) input()

D) input()

Which of the following will assign a random integer in the range of through 50 to the variable number? A) randint(1, 50) = number B) random(1, 50) = number C) number = random(range(1, 50)) D) number = random.randint(1, 50)

D) number = random.randint(1, 50)

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

D) or

Which logical operators perform short-circuit evaluation? A) or, not B) not, and C) and, or, not D) or, and

D) or, and

A(n) ________ is a variable that receives an argument that is passed into a function. A) argument B) global variable C) named constant D) parameter

D) parameter

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) first input B) loop set read C) loop validation D) priming read

D) priming read

A(n) ________ structure is a structure that causes a statement or a set of statements to execute repeatedly. A) decision B) sequence C) module D) repetition

D) repetition

Programs are commonly referred to as _____ A) system software B) utility programs C) application software D) software

D) software

What type of function can be used to determine whether a number is even or odd? A) Boolean B) odd C) even D) math

A) Boolean

What will be displayed after the following code is executed? def pass_it(x, y): z = x*y result = get_result(z) return(result) def get_result(number): z = number + 2 return(z) num1 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer) A) 14 B) 9 C) 12 D) Nothing, this code contains a syntax error.

A) 14

What will display after the following code is executed? def main(): print("The answer is",magic(5)) def magic(num): answer = num + 2 * 10 return answer main() A) 25 B) 100 C) 70 D) The statement will cause a syntax error.

A) 25

What will be the output after the following code is executed? def pass_it(x, y): z = y**x return(z) num1 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer) A) 64 B) 81 C) 12 D) None

A) 64

Which of the following is not an augmented assignment operator? A) <= B) += C) *= D) /=

A) <=

In Python the ________ symbol is used as the equality operator. A) == B) != C) <= D) <>

A) ==

Which mathematical operator is used to raise 5 to the second power in Python? A) ^ B) ** C) ~ D) /

B) **

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

B) 157

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) True C) B D) False

B) True

A Boolean variable can reference one of two values which are A) or B) True or False C) yes or no D) or

B) True or False

A value-returning function is... A) a single statement that performs a specific task B) a function that will return a value back to the part of the program that called it C) called when you want the function to stop D) a function that receives a value when called

B) a function that will return a value back to the part of the program that called it

A(n) ________ is any piece of data that is passed into a function when the function is called. A) global variable B) argument C) parameter D) local variable

B) argument

The Python turtle is initially positioned in the ________ of a graphics window and it first appears, by default, to be heading ________. A) bottom left corner, down B) center, east C) center, up D) top left corner, east

B) center, east

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

B) counting counting counting counting

When a function is called by its name during the execution of a program, then it is A) defined B) executed C) exported D) located

B) executed

The process known as the ________ cycle is used by the CPU to execute instructions in a program. A) decode-execute-fetch B) fetch-decode-execute C) decode-fetch-execute D) fetch-execute-decode

B) fetch-decode-execute

A(n) ________ is a diagram that graphically depicts the steps that take place in a program? A) algorithm B) flowchart C) source code D) pseudocode

B) flowchart

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

B) if y >= 10 and y <= 50:

To use Python's turtle graphics, you must include which of the following statements in your program? A) import Turtle B) import turtle C) import turtle_graphics D) import turtle_module

B) import turtle

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

B) in main memory

The following is an example of an instruction written in which computer language? 10110000 A) Java B) machine language C) C# D) Assembly language

B) machine language

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

B) magnetically

The ________ of a local variable is the function in which that variable is created. A) global reach B) scope C) definition D) space

B) scope

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

B) standard

Which type of error prevents the program from running? A) grammatical B) syntax C) human D) logical

B) syntax

In Python, the variable in the for clause is referred to as the ________ because it is the target of an assignment at the beginning of each loop iteration. A) count variable B) target variable C) for variable D) loop variable

B) target variable

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

B) top-down

The encoding technique used to store negative numbers in the computer's memory is called. A) floating-point notation B) two's complement C) Unicode D) ASCII

B) two's complement

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

C) and

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

C) 0, 1, 2, 3

What is the largest value that can be stored in one byte? A)8 B) 65535 C) 255 D) 128

C) 255

After the execution of the following statement, the variable price will reference the value ________. price = int(68.549) A) 68.55 B) 69 C) 68 D) 68.6

C) 68

What will be displayed after the following code is executed? total = 0 for count in range(4,6): total += count print(total) A) 4 5 6 B) 4 5 C) 9 D) 4 9

C) 9

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

C) ENIAC

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

C) False

What will be the output after the following code is executed? def pass_it(x, y): z = x + ", " + y return(z) name2 = "Tony" name1 = "Gaddis" fullname = pass_it(name1, name2) print(fullname) A) Tony, Gaddis B) Tony Gaddis C) Gaddis, Tony D) Gaddis Tony

C) Gaddis, Tony

What is the output of the following print statement? print 'I\'m ready to begin' A) 'I\'m ready to begin' B) I\'m ready to begin C) I'm ready to begin D) Im ready to begin

C) I'm ready to begin

The decision structure that has two possible paths of execution is known as. A) two alternative B) double alternative C) dual alternative D) single alternative

C) dual alternative

A ________ constant is a name that references a value that cannot be changed while the program runs... A) local B) keyword C) global D) string

C) global

It is recommended that programmers avoid using ________ variables in a program whenever possible. A) keyword B) local C) global D) string

C) global

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

C) import random

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) output() B) str_input() C) input() D) eval_input()

C) input()

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called... A) sequence B) value C) list D) variable

C) list

The Python standard library's ________ module contains numerous functions that can be used in mathematical calculations. A) string B) number C) math D) random

C) math

Which of the following will display 20%? A) print(format(0.2 * 100, '.0%')) <enter> B) print(format(20, '.0%')) <enter> C) print(format(0.2, '.0%')) <enter> D) print(format(0.2, '%')) <enter>

C) print(format(0.2, '.0%')) <enter>

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) pseudocode D) source code

C) pseudocode

What is the process of retrieving data from a file called? A) reading input B) getting data C) reading data D) retrieving data

C) reading data

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

C) solid state drive

When will the following loop terminate? while keep_on_going != 999: A) when keep_on_going refers to a value greater than 999 B) when keep_on_going refers to a value not equal to 999 C) when keep_on_going refers to a value equal to 999 D) when keep_on_going refers to a value less than 999

C) when keep_on_going refers to a value equal to 999

What does the following expression mean? x <= y A) x is greater than y B) x is less than y C) x is less than or equal to y D) x is greater than or equal to y

C) x is less than or equal to y

Which of the following functions returns the largest integer that is less than or equal to its argument? A) lesser B) greater C) ceil D) floor

D) floor

In Python the ________ symbol is used as the not-equal-to operator. A) <= B) == C) <> D) !=

D) !=

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

D) 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

D) 30

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total) A) 5 B) 1 C) 1 4 D) 6

D) 6

The ________ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer's memory. A) two's complement B) ENIAC C) Unicode D) ASCII

D) ASCII

Which computer language uses short words known as mnemonics for writing programs? A) Pascal B) Java C) Visual Basic D) Assembly

D) Assembly

Which language is referred to as a low-level language? A) Python B) C++ C) Java D) Assembly language

D) Assembly language

Which of the following is not a microprocessor manufacturing company? A) AMD B) Motorola C) Intel D) Dell

D) Dell

What does the following program do? student = 1 while student <= 3: total = 0 for score in range(1, 4): score = int(input("Enter test score: ")) total += score average = total/3 print("Student ", student, "average: ", average) student += 1 67) A) It accepts 4 test scores for 2 students, then averages and outputs all the scores. B) It accepts one test score for each of 3 students and outputs the average of the 3 scores. C) It accepts 4 test scores for 3 students and outputs the average of the 12 scores. D) It accepts 3 test scores for each of 3 students and outputs the average for each student

D) It accepts 3 test scores for each of 3 students and outputs the average for each student

What will be the output after the following code is executed? def pass_it(x, y): z = x , ", " , y num1 = 4 num2 = 8 answer = pass_it(num1, num2) print(answer) A) 4, 8 B) 48 C) 8, 4 D) None

D) None

Which of the following describes what happens when a piece of data is written to a file? A) The data is copied from a variable in the program to a file. B) The data is copied from a file object to a file. C) The data is copied from the program to a file. D) The data is copied from a variable in RAM to a file

D) The data is copied from a variable in RAM to a file

What is a group of statements that exists within a program for the purpose of performing a specific task? A) a subprocess B) a subtask C) a process D) a function

D) a function

What symbol is used to mark the beginning and end of a string? A) an asterisk ( ) B) a comma ( ) C) a slash ( ) D) a quote mark ( )

D) a quote mark ( )

What type of loop structure repeats the code a specific number of times? A) number-controlled loop B) condition-controlled loop C) Boolean-controlled loop D) count-controlled loop

D) count-controlled loop

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) newLine C) separator D) end

D) 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) str B) currency C) int D) float

D) float


Related study sets

Adjustable rate mortgages (ARMS)

View Set

Chapter 1 Reading Guides and Test candidate questions

View Set

Ch 12: 3-D Physiology: Membrane Potentials: Graded and Action Potentials

View Set

The Declaration of Independence - The American Revolution

View Set

IS245 - CHAPTER 01 TO 06 / EXCEPT CH 5

View Set