Each of the following questions are worth 3 points.
True and False
Control C
built-in functions
a local variable
literals, variables, calculations, function calls
a file object
open
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
read and execute permission
a sequence
a sequence object that can be changed
a sequence object that cannot be changed
+ and *
l1 = [1, 2, 3, 4, 5]
4 in l1
l1.append(6)
l1.sort()
l2 = l1
a new list variable pointing to the same list as l1
56.37 45.133 29.8145The 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
average_list which takes one
parameter, num_list, a list of integers. def average_list(num_list):
total = 0
for num in num_list:
total += num
return round(total/len(num_list), 2)
count_chars. s, a string,
and char, a character. char
appears in s and return that value. def count_chars(s, char):
letter_count = 0
for ch in s:
if ch == char:
letter_count += 1
return letter_count