diff --git a/__pycache__/lec_3_my_module.cpython-312.pyc b/__pycache__/lec_3_my_module.cpython-312.pyc new file mode 100644 index 000000000..335895cbe Binary files /dev/null and b/__pycache__/lec_3_my_module.cpython-312.pyc differ diff --git a/dop_1.py b/dop_1.py new file mode 100644 index 000000000..666b3df4a --- /dev/null +++ b/dop_1.py @@ -0,0 +1,16 @@ +print("ax^2 + bx + c = 0") +a = int(input("Введите коэффициент a: ")) +b = int(input("Введите коэффициент b: ")) +c = int(input("Введите коэффициент с: ")) +print("Получилось крадратное уравнение:", a,"x^2 + ", b,"x + ",c,"= 0") +d = b**2 - 4*a*c +x1 = (-b - d ** 0.5)/(2*a) +x2 = (-b + d ** 0.5)/(2*a) +x3 = (-(b/2*a)) +print("Дискриминант данного уравнения равен:", d) +if d < 0: + print("Дискриминант меньше нуля,соответсвенно нет корней") +elif d == 0: + print("Дискриминант равен нулю, соответсвенно уравнение имеет 1 корень, x =",x3) +else: + print ("Дискриминант больше нуля, соответсвенно уравнение имеет 2 корня, x1 =",x1,",x2 =",x2) \ No newline at end of file diff --git a/dop_2.py b/dop_2.py new file mode 100644 index 000000000..0b7e4e898 --- /dev/null +++ b/dop_2.py @@ -0,0 +1,12 @@ +a = int(input("Введите длину первой стороны: ")) +b = int(input("Введите длину второе стороны: ")) +z = int(input("Введите длину третьей стороны: ")) +if a + b > z and a + z > b and b + z > a: + print ("Такой треугольник существует") + if a == b == z: + print("Треугольник равностронний") + elif a == b or b == z or a == z: + print("Треугольник равнобедренный") + else: + print ("Треугольник равностронний") + \ No newline at end of file diff --git a/lec_3_from.py b/lec_3_from.py new file mode 100644 index 000000000..2181a2eba --- /dev/null +++ b/lec_3_from.py @@ -0,0 +1,9 @@ +# Копирование указанных атрибутов модуля +from lec_3_my_module import a, b + +print(a * b) + +# Копирование ВСЕХ атрибутов модуля +from lec_3_my_module import * + +print(c[2] * c[1]) \ No newline at end of file diff --git a/lec_3_from_as.py b/lec_3_from_as.py new file mode 100644 index 000000000..32cd8262a --- /dev/null +++ b/lec_3_from_as.py @@ -0,0 +1,9 @@ +from lec_3_my_module import earth_mass as em +from lec_3_my_module import gravity_constant as G +from lec_3_my_module import sigma_steff_bolc as sigma + +g = 500 * G / 10**2 +print(g) + +x = em * G * sigma +print(x) \ No newline at end of file diff --git a/lec_3_import-as.py b/lec_3_import-as.py new file mode 100644 index 000000000..234a445c0 --- /dev/null +++ b/lec_3_import-as.py @@ -0,0 +1,9 @@ +# Создание псевдонима для имени модуля +import lec_3_my_module as mm + +print(mm.a) + +b = mm.b * 3 +print(b) + +print(mm.c[2] + b + mm.c[0]) \ No newline at end of file diff --git a/lec_3_inorlibs_math.py b/lec_3_inorlibs_math.py new file mode 100644 index 000000000..c9e4fb72f --- /dev/null +++ b/lec_3_inorlibs_math.py @@ -0,0 +1,9 @@ +import math +a = math.sin(3 * math.pi / 5) +print(a) +b = math.sqrt(3) +print(b) +c = math.log10(42) +print(c) +d = math.asin(math.tan(math.pi / 4)) * 180 / math.pi +print(d) \ No newline at end of file diff --git a/lec_3_my_import.py b/lec_3_my_import.py new file mode 100644 index 000000000..13185ae7a --- /dev/null +++ b/lec_3_my_import.py @@ -0,0 +1,8 @@ +# Модуль lec_3_import.py + +# Инструкция, целиком загружающая модуль +import lec_3_my_module +print(lec_3_my_module.a) +b = lec_3_my_module.b * 3 +print(b) +print(lec_3_my_module.c[2]) \ No newline at end of file diff --git a/lec_3_my_module.py b/lec_3_my_module.py new file mode 100644 index 000000000..457eb1215 --- /dev/null +++ b/lec_3_my_module.py @@ -0,0 +1,10 @@ +# Модуль lec_3_my_module.py + +# Атрибуты модуля +a = 3 +b = 'Good' +c = ['Bad', 4, 'Petya molodec'] + +earth_mass = 5.97237 * 10**30 +sigma_steff_bolc = 5.67036713 * 10**(-8) +gravity_constant = 6.67408 * 10**(-11) diff --git a/lec_3_np_array.py b/lec_3_np_array.py new file mode 100644 index 000000000..8c3c9b450 --- /dev/null +++ b/lec_3_np_array.py @@ -0,0 +1,12 @@ +# Массив это список с одиннаковым типом данных +import numpy as np +a = [1, 2, 4] +b = np.array(a) # Создание массива из списка +print(type(a)) +print(type(b)) +print(b * b) +print(b / b) +print(b - b) +c = np.append(b, "Good") +print(c) +print(b[-1]) \ No newline at end of file diff --git a/lec_3_np_ndarray.py b/lec_3_np_ndarray.py new file mode 100644 index 000000000..e65234073 --- /dev/null +++ b/lec_3_np_ndarray.py @@ -0,0 +1,9 @@ +import numpy as np +a = np.zeros((2, 3)) +print(a) +a[0,2] = 5 +print(a) +b = np.ones((3, 2)) +print(b) +d = np.ndarray((3, 3)) +print(d) \ No newline at end of file diff --git a/lec_3_numpy_generators b/lec_3_numpy_generators new file mode 100644 index 000000000..23ff495d5 --- /dev/null +++ b/lec_3_numpy_generators @@ -0,0 +1,8 @@ +import numpy as np +a = range(0,5,1) +print(a) +# a = range (0, 10, 0.1) +b = np.arange(0, 5, 0.1) +print(b) +d = np.linspace(0, 5, 10) +print(d) \ No newline at end of file diff --git a/lec_3_slice b/lec_3_slice new file mode 100644 index 000000000..cdc540bcf --- /dev/null +++ b/lec_3_slice @@ -0,0 +1,13 @@ +import numpy as np +a = [1, 5, 3, 6] +slice = a[0:2:1] +print(slice) +slice = a [3:0:-1] +print(slice) +slice = a[::-1] +print(slice) +b = np.array([a, np.array(a)*3]) +print(b) +slice = b[::, 1] +print(slice) + diff --git a/lec_3_task_2.py b/lec_3_task_2.py new file mode 100644 index 000000000..4b739601e --- /dev/null +++ b/lec_3_task_2.py @@ -0,0 +1,10 @@ +import math +g = 10 +h = 100 +a = 45 +b = 35 +v = math.sqrt(g*h * math.tan**2(b) / 2 * math.cos**2(a) * (1 - math.tan(b) * math.tan(a))) +print(v) +T = 200 +E = 300 + diff --git a/lec_bool.py b/lec_bool.py new file mode 100644 index 000000000..590850ff6 --- /dev/null +++ b/lec_bool.py @@ -0,0 +1,15 @@ +print(bool(2)) + +print(bool("Good")) + +print(bool([1,4,5])) + +print(bool(0)) + +print(bool("")) + +print(bool([])) + +print(bool([[]])) + + diff --git a/lec_break-continue.py b/lec_break-continue.py new file mode 100644 index 000000000..c09194dca --- /dev/null +++ b/lec_break-continue.py @@ -0,0 +1,13 @@ +''' +if <условие прерывания>: + break / continue +''' + +for symbol in 'hello world': + if symbol == 'o': + break + print(symbol) + +for symbol in 'hello world': + if symbol == 'o': + continue \ No newline at end of file diff --git a/lec_for.py b/lec_for.py new file mode 100644 index 000000000..7a95e7aa5 --- /dev/null +++ b/lec_for.py @@ -0,0 +1,12 @@ +for i in 1, 3, 4: + print (i**2, end=" ") +for i in 1, 3, 4: + print (i**2, end="\n") +for i in 1, 3, 4: + print(i, i**2, sep=" - ") +a = [1, 5, 7, 10] +for i in a: + print(f"{i}**3 = {i**3}") + + + diff --git a/lec_if-elif-else.py b/lec_if-elif-else.py new file mode 100644 index 000000000..6c71a9046 --- /dev/null +++ b/lec_if-elif-else.py @@ -0,0 +1,7 @@ +a = 3 +if a > 5: + print("hello 5") +elif a < 2: + print("hello 2") +else: + print("Tupo hello") \ No newline at end of file diff --git a/lec_if-else.py b/lec_if-else.py new file mode 100644 index 000000000..438e43f71 --- /dev/null +++ b/lec_if-else.py @@ -0,0 +1,6 @@ +a = 3 +if a== 4: + print(f"hello 4") +else: + print(f"hello{a}") + \ No newline at end of file diff --git a/lec_if.py b/lec_if.py new file mode 100644 index 000000000..ced96ea0e --- /dev/null +++ b/lec_if.py @@ -0,0 +1,12 @@ +if 1: + print("hello 1") + + a = 3 +if a > 1: + print(f" hello {a}") + + b = 5 +if b == 5: + print(f"hello {b}") + + diff --git a/lec_logic-oper.py b/lec_logic-oper.py new file mode 100644 index 000000000..efabce770 --- /dev/null +++ b/lec_logic-oper.py @@ -0,0 +1,10 @@ +a = 3 +b = 4 +if a > 4 and b == 2: # and - операция логического И + print ("Good") +elif b > 3 or a == 5: # or - операция логоческого или + print ("Best") +else : + print ("Bad") + + diff --git a/lec_range.py b/lec_range.py new file mode 100644 index 000000000..4a177b28f --- /dev/null +++ b/lec_range.py @@ -0,0 +1,22 @@ +''' +for <переменная цикла> in range(start, stop, step): + <интсрукция_1> + <интсрукция_2> + <интсрукция_3> # Тело оператора + .... + <интсрукция_n> + +По умолчанию: start = 0, step = 1 +Диапазон генерирования: [start, stop) +''' +a = range (0, 10, 2) +print(a) +print(type(a)) +print(a[3]) +a = "Good" +for i in range(0, 10, 1): + if i < len(a): + print(a[i] + " - Bad") + else: + print(f'{i}' + " - Good") + diff --git a/lec_while.py b/lec_while.py new file mode 100644 index 000000000..648079b17 --- /dev/null +++ b/lec_while.py @@ -0,0 +1,16 @@ +# Дудос +''' +while <переменная цикла> <условие>: + <интсрукция_1> + <интсрукция_2> + <интсрукция_3> + .... + <интсрукция_n> + + <переменная цикла> += step +''' +i = 5 +while i < 15: + print("i", i) + i += 2 + diff --git a/task2_1.py b/task2_1.py new file mode 100644 index 000000000..e71fd65c2 --- /dev/null +++ b/task2_1.py @@ -0,0 +1,5 @@ +a = int (input ("Введите число: ")) +if a%2 == 0: + print("Четное") +else: + print("Нечетное") \ No newline at end of file diff --git a/task2_2.py b/task2_2.py new file mode 100644 index 000000000..52c3f7360 --- /dev/null +++ b/task2_2.py @@ -0,0 +1,6 @@ +b1 = int (input ("Введите первой член геометрической прогрессия: ")) +q = int(input( "Введите знаменательный геометрической прогрессии: ")) +n = int(input("Введите количество n чисел геометрической прогрессии: ")) +for i in range(n): + z = b1 * (q**i) + print(f"Член прогрессии №{i + 1}: {z}") diff --git a/task2_3.py b/task2_3.py new file mode 100644 index 000000000..d205fd523 --- /dev/null +++ b/task2_3.py @@ -0,0 +1,8 @@ +a = int(input("Введите год: ")) +if a%4 == 0 and a%100 != 0 or a%4 == 0 and a%400 == 0 : + print("Этот год високосный") +elif a%100 == 0 and a%400 != 0 : + print("Этот год не високосный ") +else: + print("Этот год не високосный") + \ No newline at end of file diff --git a/task2_4.py b/task2_4.py new file mode 100644 index 000000000..8be2435ec --- /dev/null +++ b/task2_4.py @@ -0,0 +1,6 @@ +n = int(input("Введите количество чисел в ряду Фибоначчи: ")) +a = b = 1 +print(a,b, end=" ") +for i in range(2,n): + a,b = b,a + b + print(b, end=" ") \ No newline at end of file diff --git a/task2_5.py b/task2_5.py new file mode 100644 index 000000000..e3f5ddc85 --- /dev/null +++ b/task2_5.py @@ -0,0 +1,8 @@ +a = int(input("Введите целое число: ")) +b = int(input("Введите целое число: ")) +if b == 0: + print ("На ноль делить нельзя") +elif a%b == 0: + print ("Число делится нацело") +elif a%b != 0: + print ("Число не делится нацело, остаток = ", a%b) diff --git a/task2_6.py b/task2_6.py new file mode 100644 index 000000000..e56b170f1 --- /dev/null +++ b/task2_6.py @@ -0,0 +1,4 @@ +for i in range(1, 10): + for z in range(1,10): + print("%4a"%(i * z), end="") + print()