diff --git a/first b/first new file mode 100644 index 0000000..82bd8fb --- /dev/null +++ b/first @@ -0,0 +1,2 @@ +text +change sth \ No newline at end of file diff --git a/week02/01.py b/week02/01.py new file mode 100644 index 0000000..68a3b47 --- /dev/null +++ b/week02/01.py @@ -0,0 +1,6 @@ +n = int(input()) +ch = n // 60 +min = n % 60 +if ch >= 24: + ch = ch % 24 +print(ch, min) diff --git a/week02/02.py b/week02/02.py new file mode 100644 index 0000000..3e31a91 --- /dev/null +++ b/week02/02.py @@ -0,0 +1,3 @@ +text = str(input()) +a = int(input()) +print("Hello" + ("," + text)*a) diff --git a/week02/03.py b/week02/03.py new file mode 100644 index 0000000..fb4c044 --- /dev/null +++ b/week02/03.py @@ -0,0 +1,9 @@ +a = int(input()) +b = int(input()) +c = int(input()) +min = a +if b < min: + min = b +if c < min: + min = c +print(min) diff --git a/week02/04.py b/week02/04.py new file mode 100644 index 0000000..0404bab --- /dev/null +++ b/week02/04.py @@ -0,0 +1,6 @@ +v = int(input()) +t = int(input()) +if v > 0: + print((v * t) % 109) +else: + print((109 + (v * t)) % 109) diff --git a/week02/05.py b/week02/05.py new file mode 100644 index 0000000..9476990 --- /dev/null +++ b/week02/05.py @@ -0,0 +1,12 @@ +def factorial(n): + if n == 0: + return 1 + else: + return n * factorial(n - 1) + + +n = int(input()) +ans = 0 +for i in range(1, n + 1): + ans += factorial(i) +print(ans) diff --git a/week02/06.py b/week02/06.py new file mode 100644 index 0000000..a82e438 --- /dev/null +++ b/week02/06.py @@ -0,0 +1,12 @@ +maks = int(input()) +prev = int(input()) +if maks < prev: + maks, prev = prev, maks +n = int(input()) +while n != 0: + if n > maks: + prev, maks = maks, n + elif n > prev: + prev = n + n = int(input()) +print(prev) diff --git a/week02/07.py b/week02/07.py new file mode 100644 index 0000000..3a41a19 --- /dev/null +++ b/week02/07.py @@ -0,0 +1,3 @@ +a = input().split() +for i in range(0, len(a), 2): + print(a[i]) diff --git a/week02/08.py b/week02/08.py new file mode 100644 index 0000000..d433aa7 --- /dev/null +++ b/week02/08.py @@ -0,0 +1,5 @@ +a = input() +s= a.split() +for num in s: + if int(num) % 2 == 0: + print(num) diff --git a/week02/09.py b/week02/09.py new file mode 100644 index 0000000..0e154db --- /dev/null +++ b/week02/09.py @@ -0,0 +1,10 @@ +def distance(x1, y1, x2, y2): + dist = ((y2 - y1) ** 2 + (x2 - x1) ** 2) ** (1 / 2) + return dist + + +x1 = float(input()) +y1 = float(input()) +x2 = float(input()) +y2 = float(input()) +print(distance(x1, y1, x2, y2)) diff --git a/week07/vector.py b/week07/vector.py new file mode 100644 index 0000000..db5d547 --- /dev/null +++ b/week07/vector.py @@ -0,0 +1,57 @@ +class Vector: + def __init__(self, x, y): + self.x = x + self.y = y + + def __repr__(self): + return 'Vector({}, {})'.format(self.x, self.y) + + def __str__(self): + return "Координатное представление вектора:" + '({}, {})'.format(self.x, self.y) + + def __add__(self, other): + return self.x + other.x, self.y + other.y + + def __lt__(self, other): + return self.x < other.x or self.x == other.x and self.y < other.y + + def __eq__(self, other): + return self.x == other.x and self.y == other.y + + def __ne__(self, other): + return self.x != other.x or self.y != other.y + + def __radd__(self, other): + return self.x + other.x, self.y + other.y + + def __iadd__(self, other): + self.x += other.x + self.y += other.y + return self + + def __sub__(self, other): + return self.x - other.x, self.y - other.y + + def __rsub__(self, other): + return other.x - self.x, other.y - self.y + + def __neg__(self): + return self.x, self.y + + def __isub__(self, other): + self.x -= other.x + self.y -= other.y + return self + + def __bool__(self): + return self.x != 0 and self.y != 0 + + def __abs__(self): + return ((self.x) ** 2 + (self.y) ** 2) ** (1 / 2) + + +if __name__ == '__main__': + a = Vector(3, 4) + b = Vector(2, 3) + print(abs(a)) +