#1
#a)
def Unknown(x, y):
if x < y:
print(str(x+y))
return input((Unknown(x+1, y) * 2))
elif x == y:
return 1
else:
print(str(x+y))
return int((Unknown(x-1,y)/2))
#b
print('10 and 15')
print(str(Unknown(10,15)))
print('10 and 10')
print(str(Unknown(10,10)))
print('15 and 10')
print(str(Unknown(15,10)))
#ii)
#won't print right
#c
def IterativeUnknown(x,y):
#base case
Total = 1
while x != y:
print(str(x+y))
if x < y:
x = x + 1
Total = Total * 2
else:
x = x - 1
Total = Total / 2
return
print('10 and 15')
print(str(IterativeUnknown(10,15)))
print('10 and 10')
print(str(IterativeUnknown(10,10)))
print('15 and 10')
print(str(IterativeUnknown(15,10)))
#d screenshot result
#2
#a
class Picture():
def __init__(self, DescriptionP, WidthSizeP, HeightSizeP, FrameColourP):
self.__Descripti
self.__WidthSize = WidthSizeP
self.__HeightSize = HeightSizeP
self.__FrameColour = FrameColourP
#b
def GetDescription(self):
return self.__Description
def GetHeight(self):
return self.__HeightSize
def GetWidth(self):
return self.__WidthSize
def GetColour(self):
return self.__FrameColour
#c
def SetDescription(self, description):
self.__Descripti
#d
Array = [None] * 100 #TYPE Picture
#e
def ReadData(Array):
Count = 0
try:
file = open('Pictures.txt', 'r')
Descripti
while Description != '':
Width = int(file.readline().strip())
Height = int(file.readline().strip())
Frame = int(file.readline().strip())
myObject = Picture(Description,Width,Height,Frame) #here
Count Count + 1
file.close()
except IOError:
print('File not found')
return Count
#f
#call the function ReadData()
ReadData(Array) #here
#g
UserEnteredColour = input('Enter your color requirements for the picture')
UserEnteredMaxWidth = input('Enter your maximum width requirements for the picture')
UserEnteredMaxHeight = input('Enter your maximum height requirements for the picture')
for element in Array:
if UserEnteredColour == element.GetColour() and UserEnteredMaxWidth == element.GetWidth() and UserEnteredMaxHeight == element.GetHeight(): #the getters r not self completing here when using element
print(UserEnteredColour)
print(UserEnteredMaxWidth)
print(UserEnteredMaxHeight
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}