Quiz09

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

Given this statement: scores = [] #creates an empty list What is the value of: len(scores)

0

What is displayed by the following Python code? nums = [3,6,9,15] nums.append (18) print (nums[1]+nums[4])

24

An entire list cannot be returned by a function, only individual elements.

False

What do we call x in the following statement: scores[x]=scores[3]

Index

When can a programmer use this function? def printList(arr) for i in arr: print(i)

This function can be used to print the elements in a list of numbers or a list of strings

A list element can be used as the argument in a function call.

True

When passing a list to a function, the list parameter becomes an alias for the list argument. Any changes within the function to the list parameter actually change the list argument.

True

What does the following call return? x = 'For score and seven\t years \nago x.split()

['For','score','and','seven','years','ago']

Given the list: scores [8,2,20,19] What is the value of the following expression? scores[1:3]

[2,20]

a) fort elt in nums: print(elt) b) for idx in range (len(nums)): print(nums[idx]) c) for idx in range(len(nums)): print(idx)

a and b

Which of the following for loops will add 10 to every element in the list nums? a) for elt in nums: elt += 10 b) for idx in range(len(nums)): nums[idx] += 10 c) for idx in range(len(nums)): idx += 10

b only

Which of the following statements creates a new list pre-loaded with data?

newList = [1,2,3]

Given the following Python statement: x = [-7,4,13,15,99] What statement changes the 15 to 20

x[3] = 20


Kaugnay na mga set ng pag-aaral

Human Growth and Development Study Set Test 1

View Set

Retirement Plans and Social Security

View Set

Business Law Semester 1 Study Guide

View Set

Laws and Protocols for Air Pollution

View Set

Medical Surgical Nursing ATI PREP

View Set

Business English Exam Study Guide

View Set