Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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.B
Copy 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

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_2

Step: 3

blur-text-image_3

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

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

Answered: 1 week ago

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago