Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class Violet: def __init__(self, w): self.w = w self.j = '' self.B = 0 def carrot(self): try: return int(self.j) except: return self.j def kale(self): v
class Violet: def __init__(self, w): self.w = w self.j = '' self.B = 0 def carrot(self): try: return int(self.j) except: return self.j def kale(self): v = str(self.w*self.w) q = int(v[len(v)//2-3:len(v)//2+3]) b = int(q/999999 * 100) self.w = q self.j += str(b) self.B += 1 return b def tomato(self): return self.j def green(self): v = str(self.w*self.w) q = int(v[len(v)//2-3:len(v)//2+3]) b = int(q/999999 * 26) + 65 self.w = q self.j += chr(b) self.B += 1 return b def strawberry(self, v): q = str(v)[0] b = (self.next()//10) * q + v return b def sardine(self): return self.BCopy the class in the box below into your Python editor and write a program that performs the following operations in the order that you see below. Note that your program SHOULD NOT modify the class in any way. Simply write a main program that does the following: 1. Create 2 objects of type Violet. Each object should be initialized with a different constructor argument. The 1st object should be initialized with a constructor argument of 206097 (integer). The 2nd object should be initialized with a constructor argument of 931045 (integer). 2. Have the 1st object call its 'kale' method 5 times 3. Have the 2 nd object call its 'green' method 7 times 4. Have the 1st object call its 'carrot' method and store the result. 5. Have the 2nd object call its 'carrot' method and store the result. 6. Add all results returned by the 'carrot' method that are of an integer data type and enter them into the blank below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started