Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Assignment 1 class Calc: # below this comment implement an addition method named 'add' # below this comment implement an subtract method named 'subtract' # below this comment implement an multiply...

1 answer below »

Assignment 1

class Calc:
# below this comment implement an addition method named 'add'
# below this comment implement an subtract method named 'subtract'
# below this comment implement an multiply method named 'multiply'
# below this comment implement an divide method named 'divide'
if __name__ == '__main__':
# if you wish to test your methods you can run add them into the print statement below and run
print()

Assignment 2

class ScrabbleCalc:
# Given the below scoring list create a Scrabble word calculator that will provide the correct scores dependent on the string provided.
# Letter Value
# A, E, I, O, U, L, N, R, S, T 1
# D, G 2
# B, C, M, P 3
# F, H, V, W, Y 4
# K 5
# J, X 8
# Q, Z 10
def __init__(self):
# The initialised lists below are to be used to validate the word score
self.one_point_values = ['a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't']
self.two_point_values = ['d', 'g']
self.three_point_values = ['b', 'c', 'm', 'p']
self.four_point_values = ['f', 'h', 'v', 'w', 'y']
self.five_point_values = ['k']
self.eight_point_values = ['j', 'x']
self.ten_point_values = ['q', 'z']
# You will need to uncomment the below method and implement the code necessary to validate a word for its scrabble score
# def word_calc(self, word):
if __name__ == '__main__':
print()

Answered Same Day Nov 11, 2021

Solution

Ximi answered on Nov 13 2021
134 Votes
from functools import reduce
class Calc:
    def add(self, *args):
        return sum(args)
    def substract(self, *args):
        return reduce(lambda x,y: x-y, args)
    def multiply(self, *args):
        return reduce(lambda x,y: x*y, args)
    def divide(self, *args):
        return reduce(lambda x,y: x/y, args)
class Scra
leCalc:
    def __init__(self):
        # The initialised lists below are to be used to validate the word score
 ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here