Each of the following questions are worth 3 points.
a recursive function
there must be a condition under which recusion will stop
the recursive call must approach this condition
direct recursion
indirect recursion
yes
magic methods
__str__
a class
constructor
__init__
an instance
self
variables and methods
.*
a match with the greatest number of characters
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
sys.argv[1]
sys.exit()
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
man model year
class Vehicle:
def __init__(self, man, model, year):
self.__man = man
self.__model = model
self.__year = year
def get_man(self):
return self.__man
def get_model(self):
return self.__model
def get_year(self):
return self.__year
def __str__(self):
return self.__man + ", " + self.__model + ", " + self.__year
F(1) = 1 F(2) = 1 F(n) = F(n - 1) + F(n - 2)
def fibonacci(number):
if number == 1 or number == 2:
return 1
else:
return fibonacci(number - 1) + fibonacci(number - 2)