Each of the following questions are worth 3 points.
5 in s1
a class
key - value pairs
__init__
False
in an if
statement?
the empty string
sys.argv[1]
one occurrence of any character, except the newline
__str__
sys
.*
constructor
os.listdir('.')
no. you can only use values that are immutable, that cannot be changed
an instance
1 or more occurrences of the character that comes before it
ordinary characters, meta-characters, character classes
magic methods
a recursive function
there must be a condition under which recusion will stop
the recursive call must approach this condition
os
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)
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()
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
205.236.184.22 2.2.3.4 13.26.34.202 ...
(\d{1,3}\.\d{1,3}\.\d{1,3})