In [37]:
def main():
    a, b, a1, b1, a2, b2 = map(int, input().split())
    if (a == a1 and b == b1) or (a == a2 and b == b2):
        print(0)
    elif (a == a1 and b == b2) or (a == a2 and b == b1):
        print(1)
    elif (a1 == a2 and b == b1) or (a1 == a2 and b == b2):
        print(2)
    else:
    
        print(0)

if __name__ == '__main__':
    main()
2 2 2 2 2 2
0
In [45]:
def main():
  a1, a2, a3, a4 = map(int, input().split())
  difficulties = [a1, a2, a3, a4]
  difficulties.sort()
  if difficulties[0] != difficulties[1] and difficulties[2] != difficulties[3]:
    print(2)
  elif difficulties[0] != difficulties[1] or difficulties[2] != difficulties[3]:
    print(1)
  else:
    print(0)
    
if __name__ == '__main__':
  main()
1 0 0 0
1
In [40]:
from datetime import datetime

class Date:
    def __init__(self, day, month, year):
        self.day = day
        self.month = month
        self.year = year

    def __lt__(self, other):
        if self.year < other.year:
            return True
        elif self.year == other.year:
            if self.month < other.month:
                return True
            elif self.month == other.month:
                if self.day < other.day:
                    return True
        return False

    def __gt__(self, other):
        if self.year > other.year:
            return True
        elif self.year == other.year:
            if self.month > other.month:
                return True
            elif self.month == other.month:
                if self.day > other.day:
                    return True
        return False

    def __eq__(self, other):
        if self.year == other.year and self.month == other.month and self.day == other.day:
            return True
        return False

from datetime import date, datetime


year = int(input('Enter a year: '))
month = int(input('Enter a month: '))
day = int(input('Enter a day: '))

d1 = date(year, month, day)
d2 = Date(6, 2, 2023)

print(d1)

if d1 < d2:
    print("d1 is less than d2")
elif d1 > d2:
    print("d1 is greater than d2")
else:
    print("d1 is equal to d2")
Enter a year: 2021
Enter a month: 11
Enter a day: 11
2021-11-11
d1 is less than d2
In [57]:
class Distance:
    def __init__(self, km, m):
        self.km = km
        self.m = m

    def __add__(self, other):
        total_km = self.km + other.km
        total_m = self.m + other.m
        if total_m >= 1000:
            total_km += total_m // 1000
            total_m = total_m % 1000
        return Distance(total_km, total_m)

    def __sub__(self, other):
        total_km = self.km - other.km
        total_m = self.m - other.m
        if total_m < 0:
            total_km -= 1
            total_m += 1000
        return Distance(total_km, total_m)

    def __mul__(self, other):
        total_km = self.km * other
        total_m = self.m * other
        total_km += total_m // 1000
        total_m = total_m % 1000
        return Distance(total_km, total_m)

    def __truediv__(self, other):
        total_m = (self.km * 1000 + self.m) / other
        total_km = total_m // 1000
        total_m = int(total_m % 1000)
        return Distance(int(total_km), total_m)

    def __str__(self):
        return f"{self.km} km {self.m} m"

d1 = Distance(4, 500)
d2 = Distance(3, 200)

d3 = d1 + d2
print("Addition: ", d3)

d4 = d1 - d2
print("Subtraction: ", d4)

d5 = d1 * 2
print("Multiplication: ", d5)

d6 = d1 / 2
print("Division: ", d6)
Addition:  7 km 700 m
Subtraction:  1 km 300 m
Multiplication:  9 km 0 m
Division:  2 km 250 m
In [17]:
class Distance:
    def __init__(self, km, m):
        self.km = km
        self.m = m
        
    def __add__(self, other):
        total_km = self.km + other.km
        total_m = self.m + other.m
        if total_m >= 1000:
            total_km += total_m // 1000
            total_m = total_m % 1000
        return Distance(total_km, total_m)
    
    def __sub__(self, other):
        total_km = self.km - other.km
        total_m = self.m - other.m
        if total_m < 0:
            total_km -= 1
            total_m += 1000
        return Distance(total_km, total_m)
    
    def __mul__(self, other):
        total_km = self.km * other
        total_m = self.m * other
        total_km += total_m // 1000
        total_m = total_m % 1000
        return Distance(total_km, total_m)
    
    def __truediv__(self, other):
        total_km = self.km // other
        total_m = (self.km % other) * 1000 + self.m
        total_m = total_m // other
        return Distance(total_km, total_m)
    
    def __str__(self):
        return f"{self.km}
  File "<ipython-input-17-ea042a22ae67>", line 36
    return f"{self.km}
                      ^
SyntaxError: EOL while scanning string literal
In [38]:
class Box:
    def __init__(self, length, breadth, depth):
        self.length = length
        self.breadth = breadth
        self.depth = depth

    def volume(self):
        return self.length * self.breadth * self.depth

class WeightBox(Box):
    def __init__(self, length, breadth, depth, weight):
        super().__init__(length, breadth, depth)
        self.weight = weight

class ColorWeightBox(WeightBox):
    def __init__(self, length, breadth, depth, weight, color):
        super().__init__(length, breadth, depth, weight)
        self.color = color
In [39]:
box = Box(10, 20, 30)
print(box.volume()) 

weight_box = WeightBox(40, 50, 60, 70)
print(weight_box.volume()) 
print(weight_box.weight) 

color_weight_box = ColorWeightBox(110, 210, 320, 450, "blue")
print(color_weight_box.volume()) 
print(color_weight_box.weight) 
print(color_weight_box.color) 
6000
120000
70
7392000
450
blue
In [ ]: