CPSC 3120 Python Programming Final Questions

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

In Python the ________ symbol is used as the not-equal-to operator. <= != <> ==

!=

Which method or operator can be used to concatenate lists? concat * % +

+

What is the first negative index in a list? 0 the size of the list minus 1 -1 -0

-1

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

0, 1, 2, 3

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) 14 9 12 Nothing, this code contains a syntax error.

14

What is the decimal value of the following binary number? 10011101 8 28 156 157

157

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

2, 4, 6, 8

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() - 100 - 25 - 70 - The statement will cause a syntax error.

25

What is the largest value that can be stored in one byte?: 128 8 255 65535

255

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

30

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

6

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) 81 12 64 None

64

Which of the following is not an augmented assignment operator? /= += <= *=

<=

In Python the ________ symbol is used as the equality operator. <> == <= !=

==

Which computer language uses short words known as mnemonics for writing programs? Pascal Assembly Visual Basic Java

Assembly

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

Assembly Language

What type of function can be used to determine whether a number is even or odd? Boolean math even odd

Boolean

Which of the following is not a microprocessor manufacturing company? AMD Intel Motorola Dell

Dell

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

False

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 True 5 False 8

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) - Gaddis Tony - Tony Gaddis - Tony, Gaddis - Gaddis, Tony

Gaddis, Tony

________ 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. Correcting data Correcting input Input validation Data validation

Input validation

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 - It accepts 4 test scores for 2 students, then averages and outputs all the scores. - It accepts one test score for each of 3 students and outputs the average of the 3 scores. - It accepts 4 test scores for 3 students and outputs the average of the 12 scores. - It accepts 3 test scores for each of 3 students and outputs the average for each student.

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) 8, 4 4, 8 48 None

None

What is an advantage of using a tuple rather than a list? - Tuples are not limited in size. - There is never an advantage to using a tuple. - Processing a tuple is faster than processing a list. - Tuples can include any data as an element.

Processing a tuple is faster than processing a list.

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

RAM

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

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

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

True

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

True or False

Which list will be referenced by the variable number after the following code is executed? number = range(0, 9, 2) [0, 2, 4, 6, 8] [2, 4, 6, 8] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 3, 5, 7, 9]

[0, 2, 4, 6, 8]

What will be the value of the variable list after the following code executes?list = [1, 2, 3, 4] list[3] = 10 [1, 2, 3, 10] [1, 2, 10, 4] [1, 10, 10, 10] Nothing; this code is invalid

[1, 2, 3, 10]

What will be the value of the variable list2 after the following code executes?list1 = [1, 2, 3] list2 = [] for element in list1: list2.append(element) list1 = [4, 5, 6] [4, 5, 6] [1, 2, 3, 4, 5, 6] [1, 2, 3] Nothing; this code is invalid

[1, 2, 3]

What will be the value of the variable list after the following code executes?list = [1, 2] list = list * 3 [1, 2], [1, 2], [1, 2] [1, 2, 1, 2, 1, 2] [1, 2] * 3 [3, 6]

[1, 2], [1, 2], [1, 2]

Which of the following would you use if an element is to be removed from a specific index? a remove method an index method a del statement a slice method

a del statement

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

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

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

accumulator

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

and

The smallest storage location in a computer's memory is known as a: byte bit ketter switch

bit

Multiple Boolean expressions can be combined by using a logical operator to create ________ expressions. sequential compound logical mathematical

compound

What type of loop structure repeats the code a specific number of times? number-controlled loop condition-controlled loop count-controlled loop Boolean-controlled loop

count-controlled loop

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

counting counting counting counting

The decision structure that has two possible paths of execution is known as two alternative single alternative dual alternative double alternative

dual alternative

What are the data items in a list called? elements items values data

elements

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

executed

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

floor

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

global

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

global

It is recommended that programmers avoid using ________ variables in a program whenever possible. keyword local string global

global

The first line in a function definition is known as the function block parameter header return

header

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

if choice != 10:

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

if y >= 10 and y <= 50:

Where does a computer store a program and the data that the program is working with while the program is running?: in main memory in secondary storage in the microprocessor in the CPU

in main memory

Which method can be used to place an item at a specific index in a list? append insert add index

insert

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called variable list sequence value

list

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

machine language

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

magnetically

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

math

When working with multiple sets of data, one would typically use a(n) tuple nested list sequence list

nested list

The primary difference between a tuple and a list is that - you don't use commas to separate elements in a tuple - a tuple cannot include lists as elements - a tuple can only include string elements - once a tuple is created, it cannot be changed

once a tuple is created, it cannot be changed

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

or

Which logical operators perform short-circuit evaluation? and, or, not or, and or, not not, and

or, and

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

repetition

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. sent def result return

return

The ________ of a local variable is the function in which that variable is created. scope definition space global reach

scope

What are programs commonly referred to as? System software utility programs software application software

software

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

solid state drive

Which type of error prevents the program from running?: grammatical syntax logical human

syntax

Which of the following is not a major component of a typical computer system?: main memory the operating system secondary storage devices the CPU

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? total + number = total total = number total += number number += number

total += number

The encoding technique used to store negative numbers in the computer's memory is called: ASCII floating-point notation two's complement Unicode

two's compliment

When will the following loop terminate? while keep_on_going != 999: - when keep_on_going refers to a value greater than 999 - when keep_on_going refers to a value not equal to 999 - when keep_on_going refers to a value equal to 999 - when keep_on_going refers to a value less than 999

when keep_on_going refers to a value equal to 999

What does the following expression mean? x <= y x is greater than or equal to y x is greater than y x is less than y x is less than or equal to y

x is less than or equal to y


Ensembles d'études connexes

Precalculus - Trigonometric Identities

View Set

Personal Finance Chapter 8 Quiz True False Multiple Choice

View Set

Fagen et al (Elephant training)

View Set

Path to Field Tech I and II (to advance to FT III)

View Set

Business Essentials Review (Unit 3)

View Set

Databricks Certified Associate Developer for Apache Spark 3.0 - Python

View Set

NURS 3108 - Ch 15 Depression EAQs

View Set

Municipal Securities- Analysis, Trading and Taxation

View Set