I understand most of this information is more suitable to C++but our instructor wants us to modify it to do it in Python. Aslong as you fufill the parameters the best you can in Python andworks that all I want. Thank you
- Ask the user for the number of elements, not to exceedSORT_MAX_SIZE = 16 (put appropriate input validation)
- Ask the user for the type of data they will enter - Dollar orCIS22C_Dollar objects from Lab 1.
- Use your Dollar and CIS22C_Dollar classes from Lab 1 as-iswithout making any changes.
- Based on the input, create an appropriate array for the data tobe entered.
- Make sure your template class is contained in one file whichdoes not contain either the main or the sort function of step 4below.
- Write a helper function called RecurMergeSort such that:
- It is a standalone function not part of any class of Lab1,
- Takes in the same type of parameters as any standard MergeSortwith recursion behavior, i.e.
- void MergeSort( arr[], int size)
- Prints out how the array looks every time a recursive stepreturns back to its caller,
- In your main, allow the user to enter data of their ownchoosing up to their chosen array size. There is no sample output -you are allowed to provide user interactivity as you see fit butprograms will be graded for clarity of interaction.
- Then sort the array using your sort function of step 4. Takescreenshots to be uploaded with the project.
- In your main, make sure that the output is being written toconsole as well as an output file at the same time. Do not copy andpaste text from your console to create the output file.
- Ensure input and any other data validations as needed andprovide descriptive prompts with emphasis on usability.
- Upload your classes from Lab 1 and new code files for Lab 2,output file and the screenshots in one zip file.
Grading:
- 30 pts - EXE works from as explained above without needing anycode change
- 35 pts - your Sort function as per instructions (includingcoding style, documentation)
- 35 pts - your main demonstrating everything clearly including(including coding style, documentation and interactivity)
Please do this in PYTHON to the best of ones ability. Just tryto fufill all the requirements in PYTHON as best you can.
My lab one python code
class Dollar:
def _init_(self):
__whole = 0
__fract = 0
__name = ''
def _init_(self, whole, fract, name):
self.__whole = whole
self.__fract = fract
self.__name = name
def set_whole(self, whole):
self.__whole = whole
def set_fractional(self, fractional):
self.__fract = fractional
def set_name(self, name):
self.__name = name
def get_whole(self):
return self.__whole
def get_fractional(self):
return self.__fract
def get_name(self):
return self.__name
def _del_():
print(\"Destructor called!\")
def add_sameCurrency(self, node):
fract = self._fract + node._fract
if fract > 99:
wholePart = fract // 100
fract = fract % 100
whole = self._whole + node._whole + wholePart
return whole, fract
# Subtraction same currency
def sub_sameCurrency(self, node):
fract = 0
whole = 0
if self._fract >= node._fract:
fract = self._fract - node._fract
else:
fract = self._fract - node._fract + 100
whole = self.__whole - 1
whole += self._whole - node._whole
return whole, fract
# Checking equality/inequality
def is_equal(self, node):
if self._name == node._name:
if self.__whole == node.whole:
if self._fract == node._fract:
return True
else:
return False
else:
return False
else:
return False
# comapring same currency
def is_greater(self, node):
if self._whole > node._whole:
return True
elif self._whole == node._whole:
if self._fract > node._fract:
return True
else:
return False
def show(self):
print('The amount is: ', self._whole, '.', self._fract, ' ',self._name)
def C2D2USD(self):
self._fract = (0.74 * self._fract)
self._whole = (0.74 * self._whole)
if self.__fract > 99:
self._fract = self._fract % 10
self._whole += self._fract // 100
self.__name = 'USD'
return self
# 1000 fract = 1 whole
# 1 USD = 1.36 C2D
# 1 C2D = 0.74 USD
class CIS22C:
def _init_(self):
__whole = 0
__fract = 0
__name = ''
def _init_(self, whole, fract, name):
self.__whole = whole
self.__fract = fract
self.__name = name
# Setters and Getters
def set_whole(self, whole):
self.__whole = whole
def set_fractional(self, fractional):
self.__fract = fractional
def set_name(self, name):
self.__name = name
def get_whole(self):
return self.__whole
def get_fractional(self):
return self.__fract
def get_name(self):
return self.__name
# Destructor
def _del_():
print(\"Destructor called!\")
# Adding same currency
def add_sameCurrency(self, node):
fract = self._fract + node._fract
if fract > 99:
wholePart = fract // 1000
fract = fract % 1000
whole = self._whole + node._whole + wholePart
return whole, fract
# Subtraction same currency
def sub_sameCurrency(self, node):
fract = 0
whole = 0
if self._fract >= node._fract:
fract = self._fract - node._fract
else:
fract = self._fract - node._fract + 1000
whole = self.__whole - 1
whole += self._whole - node._whole
return whole, fract
# Checking equality/inequality
def is_equal(self, node):
if self._name == node._name:
if self.__whole == node.whole:
if self._fract == node._fract:
return True
else:
return False
else:
return False
else:
return False
# comapring same currency
def is_greater(self, node):
if self._whole > node._whole:
return True
elif self._whole == node._whole:
if self._fract > node._fract:
return True
else:
return False
def show(self):
print('The amount is: ', self._whole, '.', self.fract, ' ',self._name)
def USD2C2D(self):
self._fract = 1.36 * self.fract
self._whole = 1.36 * self._whole
if self.__fract > 999:
self._fract = self._fract % 100
self._whole += self._fract // 1000
self.__name = 'C2D'
return self
class Wallet:
def _init_(self):
array = [0, 0]
dol = Dollar(0, 0, 'USD')
array[0] = dol
c2d = CIS22C(0, 0, 'C2D')
array[1] = c2d
def _init_(self, whole, fract, name):
array = [0, 0]
if name == 'USD':
dol = Dollar(whole, fract, name)
array[0] = dol
else:
c2d = CIS22C(whole, fract, name)
array[1] = c2d
def _del_(self):
print('The object is deleted!')
def addUSD(self, node):
self[0] = self[0].add_sameCurrency(node)
def addC2D(self, node):
self[1] = self[1].add_sameCurrency(node)
def subUSD(self, node):
self[0] = self[0].sub_sameCurrency(node)
def subC2D(self, node):
self[1] = self[1].sub_sameCurrency(node)
def compareUSD(self, node):
if not self[0].is_equal(node):
if self[0].is_greater(node):
print(\"Greater\")
else:
print(\"smaller\")
else:
print('Equal')
def compareC2D(self, node):
if not self[1].is_equal(node):
if self[1].is_greater(node):
print(\"Greater\")
else:
print(\"smaller\")
else:
print('Equal')