Each of the following questions are worth 3 points.
built-in functions
an error caused by code that does not follow the rules of the Python language
not False
True
when a value in a Python statement causes the statement to fail
Control C
return
statement return more than one value?
yes
open
l2 = l1
a new list variable pointing to the same list as l1
literals, variables, calculations, function calls
the hashbang line
an error that causes the code to give incorrect results
a global variable
an infinite loop
try
block of a
try
/except
statement.
any statement that can cause a runtime error
read and execute permission
a file object
except
clauses for different exceptions?
yes
return
statement
change the list given as a parameter?
yes
l3 = l1 + l2
arguments
set count to 0
loop through the string
if a character is in the list of operators:
increment count
return count
def operators_count(str):
count = 0
for ch in str:
if ch in ["+", "-", "*", "/"]:
count += 1
return count
def count_positive(num_list):
count = 0
for num in num_list:
if num > 0:
count += 1
return count
for
loop to change the list
by adding the value of increment
to each element. [1,2,3]and the increment was 2, the list would become
[3,4,5]
def increment_list(list, increment):
for index in range(len(list)):
list[index] += increment
56.37 45.133 29.8145 ...The function should convert each line to a float and add it to the list.
def decimal_list_from_file(file):
list = []
for line in file:
list.append(float(line))
return list