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) + +st=input().split() +arr=[] +for k in st: + arr.append(int(k)) +more_than_neigh(arr) \ No newline at end of file diff --git a/week04/4py2.py b/week04/4py2.py new file mode 100644 index 0000000..21a1658 --- /dev/null +++ b/week04/4py2.py @@ -0,0 +1,14 @@ +def change_max_min(mas): + mx=max(mas) + mn=min(mas) + 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) \ No newline at end of file diff --git a/week04/4py3.py b/week04/4py3.py new file mode 100644 index 0000000..bdb874f --- /dev/null +++ b/week04/4py3.py @@ -0,0 +1,16 @@ +def num_pairs(a): + count = 0 + number = 1 + for i in range(len(a)): + if a[i] != '': + for j in range(len(a)): + if a[i] == a[j] and i != j: + number += 1 + a[j] = '' + a[i] = '' + count += number * (number - 1) / 2 + number = 1 + print(count) + +arr=[int(s) for s in input().split()] +num_pairs(arr) \ No newline at end of file diff --git a/week04/4py4.py b/week04/4py4.py new file mode 100644 index 0000000..27c9dfd --- /dev/null +++ b/week04/4py4.py @@ -0,0 +1,12 @@ +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) \ No newline at end of file diff --git a/week04/4py5.py b/week04/4py5.py new file mode 100644 index 0000000..14d3e4f --- /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..f15696d --- /dev/null +++ b/week04/4py6.py @@ -0,0 +1,11 @@ +def was_earlier(row): + a = set() + for i in range(len(row)): + if int(row[i] in a) == 0: + a.add(row[i]) + print('NO') + else: + print('YES') + +row = [int(elem) for elem in input().split()] +was_earlier(row) \ No newline at end of file diff --git a/week04/4py7.py b/week04/4py7.py new file mode 100644 index 0000000..5131b98 --- /dev/null +++ b/week04/4py7.py @@ -0,0 +1,11 @@ +def num_dif_words(N,row): + a = set() + count = 0 + for i in range(N): + for elem in row: + a.add(elem) + print(len(a)) + +num = int(input()) +lst = set(input().split()) +num_dif_words(num,lst) \ No newline at end of file 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..d73a2f8 --- /dev/null +++ b/week05/5py1.py @@ -0,0 +1,9 @@ +def degree(a,n): + res=1 + for i in range(n): + res*=a + return res + +a=int(input()) +n=int(input()) +print(degree(a,n)) \ No newline at end of file diff --git a/week05/5py3.py b/week05/5py3.py new file mode 100644 index 0000000..6409e5c --- /dev/null +++ b/week05/5py3.py @@ -0,0 +1,26 @@ +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 + +st=input() +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)) \ No newline at end of file diff --git a/week05/5py4.py b/week05/5py4.py new file mode 100644 index 0000000..6bd5957 --- /dev/null +++ b/week05/5py4.py @@ -0,0 +1,26 @@ +def count_sum(matrix,flag): + s=0 + for i in range(N): + for j in range(N): + if flag: + if i==j: + s+=matrix[i][j] + elif i+j==N-1: + s += matrix[i][j] + return s + +N=int(input()) +arr=[] +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=True +if s=='main': + k=True +elif s=='side': + k=False +print(count_sum(arr,k))