programming quiz 1

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which method or operator can be used to concatenate lists?

+

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 + 2return(z) num1 = 3num2 = 4answer = pass_it(num1, num2) print(answer)

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

25

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

30

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

4 9

Which of the following is not an augmented assignment operator?

<=

In Python the ________ symbol is used as the equality operator.

==

What does the following code segment do? Assume random module has been imported and matrix has been initialized with 3 rows and 3 columns with value 0. for row in range(len(matrix)): for column in range(len(matrix[row])): matrix[row][column] = random.randint(0, 99)

It fills the 2 dimensional list with random number between 0 and 99.

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]

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]

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]

[1, 2, 3]

What will be the value of the variable list1 after the following code executes? list1 = [] list1.append([1,2])

[[1, 2]]

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

and

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

false

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

floor

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

insert

The Python library functions that are built into the Python ________ can be used by simply calling the required function.

interpreter

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)

none

Which logical operators perform short-circuit evaluation?

or, and

The following code will sum all the elements in a 2-dimensional list of integers. Fill in the missing code. def accumulate(matrix): total = 0for row in matrix: total += ~~~~#your code here~~~~ return total

sum(row)

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

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

true

When will the following loop terminate?while keep_on_going != 999:

when keep_on_going refers to a value equal to 999


Kaugnay na mga set ng pag-aaral

Chapter 7: The Empires of Persia

View Set

Pharm Made Easy 4.0 The Genitourinary System

View Set

Ch 17: Information & Accounting Concepts

View Set

36 Art History: Characteristics of Modern Art in America, Surrealism, 34 Art History: DaDa, 33 Art History: Cubism, Modern Art in Context, 31 Art History: Modern Art in Context, Realism, 29 Art History: Impressionism, 28 Art History: Romanticism, Neo...

View Set

Chapter_3_knowledg_assessmant_70-698

View Set