Each of the following questions are worth 3 points.
key - value pairs
no. you can only use values that are immutable, that cannot be changed
False
in an if
statement?
the empty string
5 in s1
os
os.listdir('.')
sys
sys.argv[1]
ordinary characters, meta-characters, character classes
one occurrence of any character, except the newline
1 or more occurrences of the character that comes before it
.*
a class
constructor
__init__
an instance
magic methods
__str__
a recursive function
there must be a condition under which recusion will stop
the recursive call must approach this condition
205.236.184.22 2.2.3.4 13.26.34.202 ...
(\d{1,3}\.\d{1,3}\.\d{1,3})
endswith
.def python_count(dir_path):
file_list = os.listdir(dir_path)
count = 0
for file in file_list:
if file.endswith('.py'):
count += 1
return count
first_name last_name idAll attributes must be hidden and must have accessor methods.
class Employee:
def __init__(self, first_name, last_name, id):
self.__first_name = first_name
self.__last_name = last_name
self.__id = id
def get_first_name(self):
return self.__first_name
def get_last_name(self):
return self.__last_name
def get_id(self):
return self.__id
def __str__(self):
return self.__first_name + " " + self.__last_name + ", ID: " + self.get_id()
count_down(5)
, the output should be
5 4 3 2 1 0
def count_down(num):
print(num)
if num > 0:
count_down(num - 1)