diff --git a/Programme1 b/Programme1 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Programme1 @@ -0,0 +1 @@ + diff --git a/hello.py b/hello.py new file mode 100644 index 0000000..5ffd7af --- /dev/null +++ b/hello.py @@ -0,0 +1 @@ +print('hello, world') \ No newline at end of file diff --git a/week02/Py1.py b/week02/Py1.py new file mode 100644 index 0000000..15d875e --- /dev/null +++ b/week02/Py1.py @@ -0,0 +1,5 @@ +def print_hours_minutes(n): + print(n//60%24,n%60) + +n=int(input()) +print_hours_minutes(n) \ No newline at end of file diff --git a/week02/Py2.py b/week02/Py2.py new file mode 100644 index 0000000..881c3f1 --- /dev/null +++ b/week02/Py2.py @@ -0,0 +1,10 @@ +def print_string(t,n): + a=[] + a.append('Hello') + for i in range(n): + a.append(t) + print(', '.join(a)) + +text=input() +n=int(input()) +print_string(text,n) diff --git a/week02/Py3.py b/week02/Py3.py new file mode 100644 index 0000000..608623b --- /dev/null +++ b/week02/Py3.py @@ -0,0 +1,11 @@ +def find_min(a,b,c): + min_elem=a + if b0: + print(v*t%109) + else: + print((109+v*t)%109) +v=int(input()) +t=int(input()) +point(v,t) \ No newline at end of file diff --git a/week02/Py5.py b/week02/Py5.py new file mode 100644 index 0000000..e1f1315 --- /dev/null +++ b/week02/Py5.py @@ -0,0 +1,10 @@ +def sum_factorials(n): + a=1 + summar=0 + for i in range(1,n+1): + a=a*i + summar+=a + print(summar) + +n=int(input()) +sum_factorials(n) \ No newline at end of file diff --git a/week02/Py6.py b/week02/Py6.py new file mode 100644 index 0000000..94f5b18 --- /dev/null +++ b/week02/Py6.py @@ -0,0 +1,17 @@ +def find_2nd_max(arr): + mx=arr[0] + for i in range(1,len(arr)): + if arr[i]>mx: + mx=arr[i] + mx2=0 + for i in range(len(arr)): + if ((arr[i]>mx2) and (arr[i] mas[i - 1] and mas[i] > mas[i + 1]: + count += 1 + print(count) + + +arr = map(int, input().split()) +more_than_neigh(arr) diff --git a/week04/4py2.py b/week04/4py2.py new file mode 100644 index 0000000..5703141 --- /dev/null +++ b/week04/4py2.py @@ -0,0 +1,17 @@ +def change_max_min(mas): + mx = max(mas) + mn = min(mas) + imax=0 + imin=0 + for i in range(len(mas)): + if mas[i] == mx: + imax = i + if mas[i] == mn: + imin = i + mas[imax], mas[imin] = mas[imin], mas[imax] + for k in mas: + print(k, end=' ') + + +arr = [int(s) for s in input().split()] +change_max_min(arr) diff --git a/week04/4py3.py b/week04/4py3.py new file mode 100644 index 0000000..48ca0df --- /dev/null +++ b/week04/4py3.py @@ -0,0 +1,11 @@ +def num_pairs(a): + count = 0 + for i in range(len(a)): + for j in range(i+1, len(a)): + if a[i] == a[j]: + count += 1 + print(count) + + +arr = [int(s) for s in input().split()] +num_pairs(arr) diff --git a/week04/4py4.py b/week04/4py4.py new file mode 100644 index 0000000..5eb7b9e --- /dev/null +++ b/week04/4py4.py @@ -0,0 +1,13 @@ +def num_single(a): + flag = 1 + for i in range(len(a)): + for j in range(len(a)): + if a[i] == a[j] and i != j: + flag = -1 + break + if flag > 0: + print(a[i]) + flag = 1 + +arr = [int(s) for s in input().split()] +num_single(arr) diff --git a/week04/4py5.py b/week04/4py5.py new file mode 100644 index 0000000..519076b --- /dev/null +++ b/week04/4py5.py @@ -0,0 +1 @@ +print(sorted(set(input().split()) & set(input().split()), key=int)) diff --git a/week04/4py6.py b/week04/4py6.py new file mode 100644 index 0000000..7374baf --- /dev/null +++ b/week04/4py6.py @@ -0,0 +1,11 @@ +def was_earlier(row): + a = set() + for i in range(len(row)): + if row[i] in a: + print('YES') + else: + a.add(row[i]) + print('NO') + +row = [int(elem) for elem in input().split()] +was_earlier(row) diff --git a/week04/4py7.py b/week04/4py7.py new file mode 100644 index 0000000..6e0e774 --- /dev/null +++ b/week04/4py7.py @@ -0,0 +1,12 @@ +def num_dif_words(N): + a = set() + count = 0 + for i in range(N): + lst = input().split() + for elem in lst: + a.add(elem) + print(len(a)) + + +num = int(input()) +num_dif_words(num) diff --git a/week04/4py8.py b/week04/4py8.py new file mode 100644 index 0000000..5867865 --- /dev/null +++ b/week04/4py8.py @@ -0,0 +1,10 @@ +def synonim(n): + syn = dict() + for i in range(n): + a, b = input().split() + syn[a] = b + syn[b] = a + print(syn.get(input())) + +N = int(input()) +synonim(N) \ No newline at end of file diff --git a/week04/4py9.py b/week04/4py9.py new file mode 100644 index 0000000..f77383a --- /dev/null +++ b/week04/4py9.py @@ -0,0 +1,16 @@ +def most_frequent_word(n): + words = {} + for i in range(n): + s = input().split() + for word in s: + words[word] = words.get(word, 0) + 1 + mx = max(words.values()) + mas = [] + for key, value in words.items(): + if value == mx: + mas.append(key) + mas = sorted(mas) + print(mas[0]) + +N = int(input()) +most_frequent_word(N) \ No newline at end of file diff --git a/week05/5py1.py b/week05/5py1.py new file mode 100644 index 0000000..dc86bee --- /dev/null +++ b/week05/5py1.py @@ -0,0 +1,15 @@ +def degree(a:any, n:any): + if a.isdigit() and n.isdigit(): + a=int(a) + n=int(n) + res = 1 + for i in range(n): + res *= a + return res + else: + print('Type int variables') + + +a = input() +n = input() +print(degree(a, n)) diff --git a/week05/5py2.py b/week05/5py2.py new file mode 100644 index 0000000..d0a63e8 --- /dev/null +++ b/week05/5py2.py @@ -0,0 +1,29 @@ +def max_common_div(arr): + A = set() + for i in range(N): + a = arr[i] + for j in range(i + 1, N): + b = arr[j] + minelem = min(a, b) + for k in range(minelem, -1, -1): + if ((a % k == 0) and (b % k == 0)): + A.add(k) + break + + return A + + +mas = [] +N = int(input()) +if isinstance(N,int): + for i in range(N): + a = int(input()) + if isinstance(a,int): + mas.append(a) + else: + print('Type int value') +else: + print('Type int number') +B = max_common_div(mas) +for elem in B: + print(elem, ' ') diff --git a/week05/5py3.py b/week05/5py3.py new file mode 100644 index 0000000..826e0f6 --- /dev/null +++ b/week05/5py3.py @@ -0,0 +1,34 @@ +from math import pi + + +def square_circle(R): + return pi * R ** 2 + + +def square_trianlge(a, h): + return a * h / 2 + + +def square_rectangle(a, b): + return a * b + + +print('Type "circle", "triangle", "rectangle"') +st = input() +if isinstance(st, str): + if st == 'circle': + print('Enter the radius') + r = int(input()) + print(square_circle(r)) + elif st == 'triangle': + print('Enter the length of one side and the height to it') + a = int(input()) + h = int(input()) + print(square_trianlge(a, h)) + elif st == 'rectangle': + print('Enter two adjacent sides') + a = int(input()) + b = int(input()) + print(square_rectangle(a, b)) +else: + print('Type string value') diff --git a/week05/5py4.py b/week05/5py4.py new file mode 100644 index 0000000..f0c7208 --- /dev/null +++ b/week05/5py4.py @@ -0,0 +1,32 @@ +def count_sum(matrix,flag): + s=0 + for i in range(N): + for j in range(N): + if flag>0 and i==j: + s+=matrix[i][j] + elif flag<0 and i+j==N-1: + s += matrix[i][j] + return s + +N=input() +arr=[] +if not N.isdigit(): + print('Type int value') +else: + N=int(N) + for i in range(N): + line=input().split() + for j in range(N): + line[j]=int(line[j]) + arr.append(line) + print('Main or side diagonal?') + s=input() + k=0 + if isinstance(s,str): + if s=='main': + k=1 + elif s=='side': + k=-1 + else: + print('Type str value') + print(count_sum(arr,k))