Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write your answers with your explanations. Thank you! This code has five (5) fatal errors. Find them. Ignore logic errors, misleading comments, mislabeled output,

Please write your answers with your explanations. Thank you!

image text in transcribed

This code has five (5) fatal errors. Find them. Ignore logic errors, misleading comments, mislabeled output, or code that may or may not cause a problem depending on input. Identify ONLY those errors that will definitely cause a program crash function fixcolor (color val: int) -> int: if color val 255: return 255 return color val class Color(class) def init (self, red0, green0, blue0): self.red = f1xcolor (red) self.green -fixcolor (green) self.bluefixcolor (blue) 10 def str (self): return "(,HI)".format (self.red, self.gree, self.blue) 12 def add (self, color2): 13 return Color (self.red color2.red, self.green color2.green, self.blue color2.blue) 14 15 def sub (self, color2) return Color (self.redcolor2.red, self.green -color2.green, self.bluecolor2.blue) 16 17 def eq_(self, color2): if self. red-= color2. red and self.green == color2 . green \ and self.blue == color2.blue: 18 19 20 return True else: return False 21 red, green, blue str. split (input ("Enter R G B color values separated by spaces")) user-color = Color (int (red) , int (green), int (blue) ) : red colorColor (255, 0, 0) 23 24 25 26 27 28 29 30 31 if user col r == red color : print("You input the value bright red') mix = user color + red color sub - user color - blue print (mix) LINE PROBLEM This code has five (5) fatal errors. Find them. Ignore logic errors, misleading comments, mislabeled output, or code that may or may not cause a problem depending on input. Identify ONLY those errors that will definitely cause a program crash function fixcolor (color val: int) -> int: if color val 255: return 255 return color val class Color(class) def init (self, red0, green0, blue0): self.red = f1xcolor (red) self.green -fixcolor (green) self.bluefixcolor (blue) 10 def str (self): return "(,HI)".format (self.red, self.gree, self.blue) 12 def add (self, color2): 13 return Color (self.red color2.red, self.green color2.green, self.blue color2.blue) 14 15 def sub (self, color2) return Color (self.redcolor2.red, self.green -color2.green, self.bluecolor2.blue) 16 17 def eq_(self, color2): if self. red-= color2. red and self.green == color2 . green \ and self.blue == color2.blue: 18 19 20 return True else: return False 21 red, green, blue str. split (input ("Enter R G B color values separated by spaces")) user-color = Color (int (red) , int (green), int (blue) ) : red colorColor (255, 0, 0) 23 24 25 26 27 28 29 30 31 if user col r == red color : print("You input the value bright red') mix = user color + red color sub - user color - blue print (mix) LINE

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions