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]
3 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]3 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
What kind of skills does an electronics engineering tech need as requirement in the workplace?
eduard

Answer:

Electrical and electronics engineering technicians should also possess the following specific qualities: Logical-thinking skills. Electrical and electronics engineering technicians must isolate and then identify problems for the engineering staff to work on. They need good reasoning skills to identify and fix problems.

Explanation:

3 0
3 years ago
Fromwhich object do you ask for DatabaseMetaData?ConnectionResultSetDriverManagerDriver
icang [17]

Answer:

Connection

Explanation:

We can get DatabaseMetaData from the java.sql.Connection object.

The relevant API call is Connection.getMetaData().

This returns an object of the type DatabaseMetaData.

Some of the methods available as part of the DatabaseMetaData object are:

  • getDatabaseMajorVersion()
  • getDatabaseMinorVersion()
  • getDriverName()
  • getDriverVersion()
  • isReadOnly()
  • getCatalogs()
  • getTables()
  • supportsBatchUpdate()
  • supportsUnion()
8 0
3 years ago
Nick won a $1,000 lottery prize. He can't decide what he should spend the money on. For some time now, he has been planning to b
miv72 [106K]
The opportunity cost is the full cost of the trip
4 0
3 years ago
What is the difference between Data and information?​
Ksivusya [100]

Answer:

Data is a piece of an Information or a raw form of information while an Information is a processed Data.

Explanation:

An example of Data would be Alphabets of someone's name while the name would be an example of an Information.

On it's own, data makes no sense and needs to be processed to become Information which makes sense.

6 0
3 years ago
Where do you go to view and access important info about your document all in one location
kumpel [21]
The place you go to view and access important info about your document would be in the menu bar.
6 0
3 years ago
Other questions:
  • ____ takes the idea of breaking down a program into separate and reusable functions to the next level by focusing on the encapsu
    10·1 answer
  • Explain the design and development proccess?
    15·1 answer
  • PLEASE DO NOT ANSWER IT IF YOU DO NOT KNOW THEM!!
    14·2 answers
  • Which criterion can be used to select the appropriate type of network media for a network?
    8·1 answer
  • What are the possible consequences of intentional virus setting?
    14·1 answer
  • Write a program to take in a time-of-day on the command-line as 3 integers representing hours, minutes, and seconds, along with
    13·1 answer
  • Flash drive DVD and hard drive are all examples of
    6·2 answers
  • Which of the following statements are true about the code shown below in the class named Quiz? (Select all that apply.)
    7·1 answer
  • Who when and why developed python​
    9·2 answers
  • Please help me ASAP!
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!