|
| 1 | +''' |
| 2 | +Flight |
| 3 | +There is a class named Flight, which has the upTime and downTime as the properties. The class should also have a method named calculateFlight, which will return the calculated flying time. You need to complete this method. |
| 4 | +
|
| 5 | +Here, upTime denotes the time at which a given bird starts flying, and downTime is the time at which the bird lands somewhere. |
| 6 | +
|
| 7 | +You don't need to worry about input/output and object of the class. The given template will take care of it. Also, it is given the bird will fly in the morning, and will land before night of the same day. |
| 8 | +
|
| 9 | +The input will contain the upTime and downTime, in 24 hr notation as hh:mm (h is hour, and m is min). You need to calculate the flying time of the given bird (in minutes), as output. |
| 10 | +
|
| 11 | +Input |
| 12 | +First line contains upTime in the given notation. Second line contains downTime in the given notation. |
| 13 | +
|
| 14 | +Output |
| 15 | +One Integer denoting the flying time in minutes. |
| 16 | +
|
| 17 | +Example |
| 18 | +Input1: |
| 19 | +
|
| 20 | +10:55 |
| 21 | +22:55 |
| 22 | +Output1: |
| 23 | +
|
| 24 | +720 |
| 25 | +Explanation: |
| 26 | +
|
| 27 | +Flying time will be 12 hrs = 720 min. |
| 28 | +
|
| 29 | +""" |
| 30 | + uptime=map(int,self.upTime.split(":")) |
| 31 | + downTime=map(int,self.downTime.split(":")) |
| 32 | +""" |
| 33 | +''' |
| 34 | +### Define the required class here... |
| 35 | + |
| 36 | +class Flight: |
| 37 | + def __init__(self, upTime, downTime): |
| 38 | + self.upTime = upTime |
| 39 | + self.downTime = downTime |
| 40 | + |
| 41 | + def calculateFlight(self): |
| 42 | + upTime0,upTime1=[int(i) for i in self.upTime.split(":")] |
| 43 | + downTime0,downTime1=[int(i) for i in self.downTime.split(":")] |
| 44 | + time=0 |
| 45 | + if downTime0>=upTime0: |
| 46 | + time=(downTime0-upTime0)*60 |
| 47 | + time=time+(downTime1-upTime1) |
| 48 | + elif downTime0<=upTime0: |
| 49 | + time=(24+downTime0-upTime0)*60 |
| 50 | + time=time+(downTime1-upTime1) |
| 51 | + return time |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + # Your Code goes here |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +### DO NOT CHANGE ANYTHING BELOW THIS LINE |
| 62 | + |
| 63 | +if __name__ == '__main__': |
| 64 | + |
| 65 | + t1 = input() |
| 66 | + t2 = input() |
| 67 | + |
| 68 | + f1 = Flight(t1, t2) |
| 69 | + print(f1.calculateFlight()) |
| 70 | + |
0 commit comments