Each of the following questions are worth 3 points.
not False
True
an infinite loop
Control C
built-in functions
arguments
a global variable
literals, variables, calculations, function calls
return
statement return more than one value?
yes
a file object
open
read and execute permission
the hashbang line
an error caused by code that does not follow the rules of the Python language
an error that causes the code to give incorrect results
when a value in a Python statement causes the statement to fail
try
block of a
try
/except
statement.
any statement that can cause a runtime error
except
clauses for different exceptions?
yes
l2 = l1
a new list variable pointing to the same list as l1
return
statement
change the list given as a parameter?
yes
l3 = l1 + l2
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
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
def count_positive(num_list):
count = 0
for num in num_list:
if num > 0:
count += 1
return count
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