Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to make a hexadecimal convertor. The program keep telling me there is something wrong with my math operators, but I believe the

I am trying to make a hexadecimal convertor. The program keep telling me there is something wrong with my math operators, but I believe the problem is somewhere in the constructor. The tester program gives me a score of 63/100. Any advice on where I am going wrong would be great.image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

class Hexadecimal: def init_ _(self, decimal-"1128") if type (decimal) is int: if decimal 0: self. decimal=decimal else: raise ValueError ("Must be greater than zero." elif type (decimal) is list: zaise ValueEzror ("Cannot enter lists.") elif type (decimal) is float: decimal = int (decimal) if decimal 0: self. decimal decimal else: raise ValueError ("Cannot have negative floats.") elif type (decimal) is str: try: if decimal not in ["A", "B",C","D", "E", "F: decimal except ValueError as Ex: float (decimal) raise ValueError ("Cannot convert string to float.") else: self. decimalint (decimal) elif type (decimal) is str:' values = {'A': 10, 'B' :11, decimaldecimal.upper ) h values [] for letter in decimal: 'C' :12, "D":13, 'E' :14, 'F' :15) if letter in values: h_values.append (valuesietter]) else: raise ValueErro "Invalid Hexadecimal") class Hexadecimal: def init_ _(self, decimal-"1128") if type (decimal) is int: if decimal 0: self. decimal=decimal else: raise ValueError ("Must be greater than zero." elif type (decimal) is list: zaise ValueEzror ("Cannot enter lists.") elif type (decimal) is float: decimal = int (decimal) if decimal 0: self. decimal decimal else: raise ValueError ("Cannot have negative floats.") elif type (decimal) is str: try: if decimal not in ["A", "B",C","D", "E", "F: decimal except ValueError as Ex: float (decimal) raise ValueError ("Cannot convert string to float.") else: self. decimalint (decimal) elif type (decimal) is str:' values = {'A': 10, 'B' :11, decimaldecimal.upper ) h values [] for letter in decimal: 'C' :12, "D":13, 'E' :14, 'F' :15) if letter in values: h_values.append (valuesietter]) else: raise ValueErro "Invalid Hexadecimal")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago