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
os
os.listdir('.')
5 in s1
ordinary characters, meta-characters, character classes
a match with the greatest number of characters
a class
constructor
__init__
an instance
pickling
rb
magic methods
__str__
a condition under which the recursion will stop
direct recursion
indirect recursion
yes
Joe 86 Sally 100 Ben 78I am looking for a SINGLE regular expression that matches all lines
(\w+)\s+(\d+)
def file_count():
count = 0
entries = os.listdir()
for entry in entries:
if os.path.isfile(entry):
count += 1
return count
title author publisherThese attributes must be HIDDEN and have accessors.
class Book:
def __init__(self, title, author, publisher):
self.__title = title
self.__author = author
self.__publisher = publisher
def get_title(self):
return self.__title
def get_author(self):
return self.__author
def get_publisher(self):
return self.__publisher
def __str__(self):
return self.get_title() + ' by ' + self.get_author() + ', ' + self.get_publisher()
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)