1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Artemon [7]
2 years ago
6

Write a class Example() such that it has a method that gives the difference between the size of strings when the '-' (subtractio

n) symbol is used between the two objects of the class. Additionally, implement a method that returns True if object 1 is greater than object 2 and False otherwise when the (>) (greater than) symbol is used. For example: obj1 = Example('this is a string') obj2 = Example('this is another one') print(obj1 > obj2) False print(obj1-obj2) 3
Computers and Technology
1 answer:
Mariulka [41]2 years ago
3 0

Answer:

class Example:

def __init__(self, val):

self.val = val

def __gt__(self, other):

return self.val > other.val

def __sub__(self,other):

return abs(len(self.val) - len(other.val))

def main():

obj1 = Example('this is a string')

obj2 = Example('this is another one')

print(obj1 > obj2)

print(obj1 - obj2)

main()

\color{red}\underline{Output:}

You might be interested in
Which of the following sets of data would be represented best in histogram?
wariber [46]
I think it would be B. The average monthly sales for the big toy company because its giving data over history
7 0
3 years ago
Read 2 more answers
If there is an value in a array, and the same value comes at the same spot, does it cancel each other out or does it reassing th
kondaur [170]

Explanation:

In simple English, an array is a collection.

In C also, it is a collection of similar type of data which can be either of int, float, double, char (String), etc. All the data types must be same. For example, we can't have an array in which some of the data are integer and some are float.

8 0
2 years ago
What is the only language a microprocessor can process directly but most programmers almost never write programs in this code?
Phantasy [73]
Assembly language, a.k.a. machine language.
6 0
2 years ago
HELP PLEASE!!!Salman wrote a SMART goal for class. Part of the goal includes the fact that he will complete Ms. Murray's extra-
kirill115 [55]

Answer:

the answer is specific

Explanation:

5 0
3 years ago
Read 2 more answers
Outlines help you visualize the slides and the points you will include on each slide.
kvv77 [185]
I don’t know I think true
6 0
3 years ago
Other questions:
  • How does the team know what to work upon during the iteration
    6·1 answer
  • At what point is an idea protected by copyright?
    7·2 answers
  • What is a color that cannot be created by mixing other colors together?
    15·2 answers
  • How do you turn on the Track Changes feature in a word-processing document?
    12·1 answer
  • Write a Student class in Java which has a name, id_number, year (e.g. 2) and
    9·1 answer
  • Josephine is in the process of creating ads within her Standard Display campaign. She finds that there are two main ad formats t
    15·1 answer
  • Microsoft <br> Excel Module 6
    11·1 answer
  • 2.3 Code Practice: Question 1
    5·1 answer
  • Which file is usually the first file to be displayed when you navigate to a website?
    5·1 answer
  • Arrange the code so that the numbers are swapped.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!