Question

this is a python question please help me with this code thank you and appreciate it

1. Write a Boolean function between that takes two My Time objects, t1 and t2, as arguments, and returns True if the invoking

0 0
Add a comment Improve this question Transcribed image text
Answer #1
class MyTime:
        def __init__(self, hrs=0, mins=0, secs=0):
                self.hours = hrs
                self.minutes = mins
                self.seconds = secs
                
        def __eq__(self, other):
                a = self.hrs * 3600 + self.mins * 60 + self.secs
                b = other.hrs * 3600 + other.mins * 60 + other.secs

                return (a == b)

        def __ne__(self, other):
                return not (self == other)

        def __gt__(self, other):
                a = self.hrs * 3600 + self.mins * 60 + self.secs
                b = other.hrs * 3600 + other.mins * 60 + other.secs

                return (a > b)

        def __lt__(self, other):
                return not(self > other and self == other)
                
        def __le__(self, other):
                return (self < other or self == other)
        
        def __ge__(self, other):
                return (self > other or self == other)
                
        def between(self, t1, t2):
                return (self >= t1) and (self < t2)

please upvote. if any issues, ask in comments. Thanks!

Add a comment
Know the answer?
Add Answer to:
this is a python question please help me with this code thank you and appreciate it...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help! This is for python

    1.    Write a Boolean member function between that takes two MyTime objects, t1 and t2, as arguments, and returns True if the invoking object falls between the two times. Assume t1 <= t2, and make the test closed at the lower bound and open at the upper bound, i.e. return True if t1 <= current_time < t2.2.    Turn the above function into a method in the MyTime class.3.    Overload the necessary operator(s) (that is __gt__) so that instead of having...

  • CAN SOMEONE COMPLETE THIS CODE PLEASE THNK YOU!! Question - Write a program in c++ that...

    CAN SOMEONE COMPLETE THIS CODE PLEASE THNK YOU!! Question - Write a program in c++ that keeps an appointment book. Make a class Appointment that stores a description of the appointment, the appointment day, the starting time, and the ending time. Your program should keep the appointments in a sorted vector. Users can add appointments and print out all appointments for a given day. When a new appointment is added, use binary search to find where it should be inserted...

  • Can someone please help me with the following java assignment. So in this assignment you will...

    Can someone please help me with the following java assignment. So in this assignment you will begin with the starterProject I provide and then add to it.  I am also asking that before you begin you really look at the starterProject because this is the object-oriented basics. The starterProject is the exact same as the ClassClockExample.zip in Module 5.  I’ve also done this using a clock because it is something that you already know how it works.  Remember that OOD and OOP is...

  • Please comment the MIPS code to help me understand. Here is what the code accomplishes. Here...

    Please comment the MIPS code to help me understand. Here is what the code accomplishes. Here is the code, partially commented. .data Matrix: .word 41,45,5, 34,8, 15,16,23,44,48,12,32,18,47,22,8,22 .word 46,40,42,33,13,38,27,6, 29,25,18,40,47,22,26,14,3 .word 7, 48,35,9, 43,38,9, 49,28,25,42,5, 44,10,5, 38,14 .word 46,33,16,6, 13,20,31,1, 8, 17,1, 47,28,46,14,28,7 .word 32,2, 48,25,41,29,14,39,43,46,3, 39,32,49,41,28,46 .word 5, 43,2, 48,13,4, 33,41,32,19,9, 25,30,22,2, 9, 40 .word 14,47,22,18,47,3, 35,44,18,6, 33,22,11,6, 47,50,4 .word 28,34,20,30,18,27,38,5, 26,40,37,23,16,13,37,8,7 .word 48,38,39,12,10,39,23,20,21,20,33,16,24,21,25,3,46 .word 49,38,40,38,13,47,5, 13,4, 13,23,26,12,30,29,29, 3 .word 8, 20,10,13,31,7, 12,41,12,21,28,26,43,14,35,10,19 .word 49,33,25,26,24,29,46,22,7, 5, 15,41,10,31,19,41,27 .word 48,9,...

  • please help with the marked ones the programming language is python code. 23.16 Write an RGB...

    please help with the marked ones the programming language is python code. 23.16 Write an RGB class that represents an RGB color. Store the red, green. and blue components. Include a _str_0 method and a luminance method that returns the luminance of the color. Write a main() function to test your code. 23.17 Write a CD class that represents a single music cd. Store the artist, title, genre, year of release, and playing time in minutes and seconds. However, instead...

  • Please help me with the code. Thank you! Description James Vond has delivered us some intel...

    Please help me with the code. Thank you! Description James Vond has delivered us some intel that the enemy perpetrators have been tricked into going to a bank that we've wired and booby-trapped. However, we have not gotten a bank system in place and you are the only person who is capable of handling such a task. We need this plan to go off without a hitch because the money we'll be receiving will give us insight on the hideout's...

  • write the following code in java thank you and if you can, could you please write...

    write the following code in java thank you and if you can, could you please write the code in replit and sent me a link to it replit is basically like a online compiler and you can write java code on it thank you The first part is to implement one of the questions from your examination. /* A Range objects represents an integer range, such as 1-10 or 50701-50799. The lower and upper bounds of a Range are given...

  • Please help me with this Java problem. Would greatly appreciate comments in the code as well:...

    Please help me with this Java problem. Would greatly appreciate comments in the code as well: Define a class called Counter whose internal "count" variable is a basic integer counter. This class track that count from its instantiation in the constructor (can be set to any positive integer, or 0). The count should never be allowed to be negative. Include methods that will set the counter to 0, increase the count by 1, and decrease the count by 1. Include...

  • My Python file will not work below and I am not sure why, please help me...

    My Python file will not work below and I am not sure why, please help me debug! ********************************* Instructions for program: You’ll use these functions to put together a program that does the following: Gives the user sentences to type, until they type DONE and then the test is over. Counts the number of seconds from when the user begins to when the test is over. Counts and reports: The total number of words the user typed, and how many...

  • Please help me to do my assignment it should be python. Thank you Write a menu-driven...

    Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT