diff --git a/lec_all.py b/lec_all.py new file mode 100644 index 000000000..c7c37e0b1 --- /dev/null +++ b/lec_all.py @@ -0,0 +1,12 @@ +def final_func(a: float, b: int=0, c=1, *args, **kwargs): + print(f'a: {a}, b: {b}, c: {c}') + print(f'args: {args}, kwargs: {kwargs} \n') + return 'done' + + +final_func(1) +final_func(1, 'Good', 4) +final_func(1, 2, 4, 5) +final_func(1, 2, 4, 5, 1, 2, 4, 5) +final_func(1, red=0, green=1, blue=0) +final_func(1, 2, 4, 5, 1, red=0, green=1, blue=0) \ No newline at end of file diff --git a/lec_arg.py b/lec_arg.py new file mode 100644 index 000000000..53fd66ec2 --- /dev/null +++ b/lec_arg.py @@ -0,0 +1,44 @@ +def my_func(a, b): + x = 3 * a - b + return x + + +#tmp = my_func() + +def my_func(a=1, b=0): + x = 3 * a - b + return x + + +print(my_func()) +print(my_func(3, 4)) +print(my_func(3)) +print(my_func(b=3)) +print(my_func(b=3, a=9)) + + +def my_func(a, b=0): + x = 3 * a - b + return x + +# ТАК НЕЛЬЗЯ!!! +# def my_func(a=0, b): +# x = 3 * a - b +# return x + +def my_func(*args): + x = (args[0] + args[1]) / len(args) + return x + + +print(my_func(3, 4)) +print(my_func(3, 4, 8)) + + +def my_func(**kwrgs): + x = len(kwrgs) * (kwrgs['obj_1'] - kwrgs['obj_2']) + return x + + +print(my_func(obj_1=3, obj_2=4)) +print(my_func(obj_1=3, obj_2=4, obj_3=8)) \ No newline at end of file diff --git a/lec_create_f.py b/lec_create_f.py new file mode 100644 index 000000000..4e146c73d --- /dev/null +++ b/lec_create_f.py @@ -0,0 +1,27 @@ +''' +def name_func(arg1, arg2, ..., argN): # Заголовок функции + <интсрукция_1> + <интсрукция_2> + <интсрукция_3> # Тело функции + .... + <интсрукция_n> + return <значение> # Возврат результата +''' + +def mult_func(a): + x = 3 * a + return x + +def my_print(a): + print(f'Это мой принт с блэкджеком и {a}') + +tmp = mult_func(4) +print(tmp) + +print(mult_func(10)) + +print(mult_func('Good')) + +my_print('Hello') + +my_print(mult_func('50')) \ No newline at end of file diff --git a/lec_local_change,py b/lec_local_change,py new file mode 100644 index 000000000..47b0693d5 --- /dev/null +++ b/lec_local_change,py @@ -0,0 +1,16 @@ +def changer(a: int, b: list): + a = 2 + b[0] = 'Good' + + +x = 10 +y = [1, 2] + +changer(x, y) +print(x) +print(y) + +y = [1, 2] + +changer(x, y[:]) +print(y) \ No newline at end of file diff --git a/lec_obl.py b/lec_obl.py new file mode 100644 index 000000000..d51f94502 --- /dev/null +++ b/lec_obl.py @@ -0,0 +1,20 @@ +x0 = 10 # Переменная в глобальной области видимости + + +def move(t): + x = x0 * t # Переменная в локальной области видимости + return x + + +print(move(3)) +# print(x) + +a = 'Good' + +def test_local_data(): + a = 'Bad' + print(a,id(a)) + +test_local_data() +print(a,id(a)) + diff --git a/lec_op.py b/lec_op.py new file mode 100644 index 000000000..09fc7596c --- /dev/null +++ b/lec_op.py @@ -0,0 +1,16 @@ +def crutoi_chuvak(a=1, b=1, c=1): + ''' + Мотивирующая функция, возвращаюая всегда значение + "Крутой чувак", независимо от того какие аргументы + Вы в нее запихали + ''' + a = 'Pofig' + b = 'Pofig' + + print('Куртой чувак') + + +crutoi_chuvak() + +help(crutoi_chuvak) +help(print) \ No newline at end of file diff --git a/lec_return.py b/lec_return.py new file mode 100644 index 000000000..7bc5fa87c --- /dev/null +++ b/lec_return.py @@ -0,0 +1,13 @@ +def my_func(a, b): + x1 = 3 * a - 2 * b + x2 = 5 * b - 4 * a + return x1, x2 #это кортеж + + +tmp = my_func(3, 2) + +print(tmp) +print(tmp[0]) +print(tmp[1]) + +print(my_func(3, 2)[1]) \ No newline at end of file diff --git a/lec_tip.py b/lec_tip.py new file mode 100644 index 000000000..95e7ff2df --- /dev/null +++ b/lec_tip.py @@ -0,0 +1,49 @@ +"""Типы данных +Неизменяемые данные (unmutable) +Числовые данные (int, float, complex) +Символьные строки (str) +Кортежи (tuple) +Списки (list) +Изменяемые данные (mutable) +Множества (set) +Словари (dict)""" + +# Coplex numbers +x = 3 +y = 4 + +z = complex(x, y) +print(z) + +w = complex(y, x) +print(z + w) + +# Strings +s = 'hello' +print(s[0]) + +# s[0] = 'H' + +# Tuple кортедж - неизменяемый список +t = (1, 4, 9) +print(t) +print(t[0]) + +# t[0] = 3 + +# list список +l = [1, 4, 9] +l[0] = 3 +print(l) + +# Dict словари +d = {'key_1':4, 2:'red', 'str':'Hello'} +print(d['key_1']) +print(d[2]) +print(d['str']) + +d['str'] = 'Good' +print(d) + +d['new_key']='Best' +print(d) \ No newline at end of file diff --git a/task_D_1.py b/task_D_1.py new file mode 100644 index 000000000..278bf0adf --- /dev/null +++ b/task_D_1.py @@ -0,0 +1,3 @@ +school_journal = {} +def add_subjects (): + \ No newline at end of file diff --git a/task_O_1.py b/task_O_1.py new file mode 100644 index 000000000..fde5a0c6a --- /dev/null +++ b/task_O_1.py @@ -0,0 +1,5 @@ +def E_meh(**data): + E=data['m']*9.8*data['h']+data['m']*data['v']**2/2 + print(E) +arg = {'m': 30, 'h': 45, 'v': 22} +E_meh(**arg) diff --git a/task_O_2.py b/task_O_2.py new file mode 100644 index 000000000..c305ca3b2 --- /dev/null +++ b/task_O_2.py @@ -0,0 +1,13 @@ +def s(*i): + return sum(i)/len(i) +print(s(1, 2, 3, 4, 5)) + +def mean_p(*i): + s = 0 + for arg in args: + s+=arg + return s/len(args) +args = (1, 2, 3, 4, 5) +mean = mean_p(1, 2, 3, 4, 5) +print(mean) + \ No newline at end of file diff --git a/task_O_3.py b/task_O_3.py new file mode 100644 index 000000000..dc6e3f618 --- /dev/null +++ b/task_O_3.py @@ -0,0 +1,13 @@ +def s(a,b,n): + y_m = [] + x_m = [] + for x in range(a,b,n): + y=x**2 + y_m.append(y) + x_m.append(x) + #print(y) + X = {'x':y_m} + Y = {'y':x_m} + return X, Y + +print(s(2,8,1)) diff --git a/task_O_4.py b/task_O_4.py new file mode 100644 index 000000000..c4e004d0b --- /dev/null +++ b/task_O_4.py @@ -0,0 +1,9 @@ +f = input('Выбeрете, площадь какой фигуры вы ищите:kr/pr/tr') +if f =='kr': + + +def s(pi=3.14,r,a,b,h): + s_kr=pi+r**2 + s_pr=a*b + s_tr=0.5*a*h +print(s()) \ No newline at end of file